<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="diff-s.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="nav-div.js"></script>
</head>
<body>
<div id="left" class="src">
<pre>
<a id='leftstart' tid='rightstart'></a>
<span class='d'>;;; -*- Mode: Emacs-Lisp; outline-regexp: &quot;\n;;;;+&quot; -*-
</span>
<span class='d'>;;;;;; Paredit: Parenthesis-Editing Minor Mode
</span><span class='d'>;;;;;; Version 20
</span>
<span class='d'>;;; This code is written by Taylor R. Campbell (except where explicitly
</span><span class='d'>;;; noted) and placed in the Public Domain.  All warranties are
</span><span class='d'>;;; disclaimed.
</span>
<span class='d'>;;; Add this to your .emacs after adding paredit.el to /path/to/elisp/:
</span><span class='d'>;;;
</span><span class='d'>;;;   (add-to-list &#39;load-path &quot;/path/to/elisp/&quot;)
</span><span class='d'>;;;   (autoload &#39;paredit-mode &quot;paredit&quot;
</span><span class='d'>;;;     &quot;Minor mode for pseudo-structurally editing Lisp code.&quot;
</span><span class='d'>;;;     t)
</span><span class='d'>;;;   (add-hook &#39;...-mode-hook (lambda () (paredit-mode +1)))
</span><span class='d'>;;;
</span><span class='d'>;;; Usually the ... will be lisp or scheme or both.  Alternatively, you
</span><span class='d'>;;; can manually toggle this mode with M-x paredit-mode.  Customization
</span><span class='d'>;;; of paredit can be accomplished with `eval-after-load&#39;:
</span><span class='d'>;;;
</span><span class='d'>;;;   (eval-after-load &#39;paredit
</span><span class='d'>;;;     &#39;(progn ...redefine keys, &c....))
</span><a id='4627' tid='4628' class='u'>;;;
</a><span class='d'>;;; This should run in GNU Emacs 21 or later and XEmacs 21.5 or later.
</span><span class='d'>;;; It is highly unlikely to work in earlier versions of GNU Emacs, and
</span><span class='d'>;;; it may have obscure problems in earlier versions of XEmacs due to
</span><span class='d'>;;; the way its syntax parser reports conditions, as a result of which
</span><span class='d'>;;; the code that uses the syntax parser must mask *all* error
</span><span class='d'>;;; conditions, not just those generated by the syntax parser.
</span>
<span class='d'>;;; This mode changes the keybindings for a number of simple keys,
</span><span class='d'>;;; notably (, ), &quot;, \, and ;.  The bracket keys (round or square) are
</span><span class='d'>;;; defined to insert parenthesis pairs and move past the close,
</span><span class='d'>;;; respectively; the double-quote key is multiplexed to do both, and
</span><span class='d'>;;; also insert an escape if within a string; backslashes prompt the
</span><span class='d'>;;; user for the next character to input, because a lone backslash can
</span><span class='d'>;;; break structure inadvertently; and semicolons ensure that they do
</span><span class='d'>;;; not accidentally comment valid structure.  (Use M-; to comment an
</span><span class='d'>;;; expression.)  These all have their ordinary behaviour when inside
</span><span class='d'>;;; comments, and, outside comments, if truly necessary, you can insert
</span><span class='d'>;;; them literally with C-q.
</span><span class='d'>;;;
</span><span class='d'>;;; These keybindings are set up for my preference.  One particular
</span><span class='d'>;;; preference which I&#39;ve seen vary greatly from person to person is
</span><span class='d'>;;; whether the command to move past a closing delimiter ought to
</span><span class='d'>;;; insert a newline.  Since I find this behaviour to be more common
</span><span class='d'>;;; than that which inserts no newline, I have ) bound to it, and the
</span><span class='d'>;;; more involved M-) to perform the less common action.  This bothers
</span><span class='d'>;;; some users, though, and they prefer the other way around.  This
</span><span class='d'>;;; code, which you can use `eval-after-load&#39; to put in your .emacs,
</span><span class='d'>;;; will exchange the bindings:
</span><span class='d'>;;;
</span><span class='d'>;;;   (define-key paredit-mode-map (kbd &quot;)&quot;)
</span><span class='d'>;;;     &#39;paredit-close-parenthesis)
</span><span class='d'>;;;   (define-key paredit-mode-map (kbd &quot;M-)&quot;)
</span><span class='d'>;;;     &#39;paredit-close-parenthesis-and-newline)
</span><a id='4629' tid='4630' class='u'>;;;
</a><span class='d'>;;; Paredit also changes the bindings of keys for deleting and killing,
</span><span class='d'>;;; so that they will not destroy any S-expression structure by killing
</span><span class='d'>;;; or deleting only one side of a bracket or quote pair.  If the point
</span><span class='d'>;;; is on a closing bracket, DEL will move left over it; if it is on an
</span><span class='d'>;;; opening bracket, C-d will move right over it.  Only if the point is
</span><span class='d'>;;; between a pair of brackets will C-d or DEL delete them, and in that
</span><span class='d'>;;; case it will delete both simultaneously.  M-d and M-DEL kill words,
</span><span class='d'>;;; but skip over any S-expression structure.  C-k kills from the start
</span><span class='d'>;;; of the line, either to the line&#39;s end, if it contains only balanced
</span><span class='d'>;;; expressions; to the first closing bracket, if the point is within a
</span><span class='d'>;;; form that ends on the line; or up to the end of the last expression
</span><span class='d'>;;; that starts on the line after the point.
</span><a id='4631' tid='4632' class='u'>;;;
</a><span class='d'>;;; Automatic reindentation is performed as locally as possible, to
</span><span class='d'>;;; ensure that Emacs does not interfere with custom indentation used
</span><span class='d'>;;; elsewhere in some S-expression.  It is performed only by the
</span><span class='d'>;;; advanced S-expression frobnication commands, and only on the forms
</span><span class='d'>;;; that were immediately operated upon (& their subforms).
</span><a id='4633' tid='4634' class='u'>;;;
</a><span class='d'>;;; This code is written for clarity, not efficiency.  S-expressions
</span><span class='d'>;;; are frequently walked over redundantly.  If you have problems with
</span><span class='d'>;;; some of the commands taking too long to execute, tell me, but first
</span><span class='d'>;;; make sure that what you&#39;re doing is reasonable: it is stylistically
</span><span class='d'>;;; bad to have huge, long, hideously nested code anyway.
</span><span class='d'>;;;
</span><span class='d'>;;; Questions, bug reports, comments, feature suggestions, &c., can be
</span><span class='d'>;;; addressed to the author via mail on the host mumble.net to campbell
</span><span class='d'>;;; or via IRC on irc.freenode.net in the #paredit channel under the
</span><span class='d'>;;; nickname Riastradh.
</span>
<span class='d'>;;; This assumes Unix-style LF line endings.
</span>
<span class='d'>(defconst paredit-version 20)</span>

(<a id='667' tid='668' class='m'>eval-and-compile</a>

  (<a id='653' tid='654' class='m'>defun</a> <a id='655' tid='656' class='m'>paredit-xemacs-p</a> ()
    <span class='d'>;; No idea I got this definition from.  Edward O&#39;Connor (hober on
</span>    <span class='d'>;; IRC) suggested the current definition.
</span>    <a id='657' tid='658' class='m'>;;   (and (boundp &#39;running-xemacs)
</a>    <a id='659' tid='660' class='m'>;;        running-xemacs)
</a>    (<a id='661' tid='662' class='m'>featurep</a> <a id='663' tid='664' class='m'>&#39;</a><a id='665' tid='666' class='m'>xemacs</a>))

  (<a id='613' tid='614' class='m'>defun</a> <a id='615' tid='616' class='m'>paredit-gnu-emacs-p</a> ()
    (<a id='617' tid='618' class='m'>not</a> (<a id='619' tid='620' class='m'>paredit-xemacs-p</a>)))

  (<a id='669' tid='670' class='m'>defmacro</a> <a id='671' tid='672' class='m'>xcond</a> (<a id='673' tid='674' class='m'>&rest</a> <a id='675' tid='676' class='m'>clauses</a>)
    <a id='677' tid='678' class='m'>&quot;Exhaustive COND.
Signal an error if no clause matches.&quot;</a>
    <a id='679' tid='680' class='m'>`</a>(<a id='681' tid='682' class='m'>cond</a> <a id='683' tid='684' class='m'>,</a><a id='685' tid='686' class='m'>@clauses</a>
           (<a id='687' tid='688' class='m'>t</a> (<a id='689' tid='690' class='m'>error</a> <a id='691' tid='692' class='m'>&quot;XCOND lost.&quot;</a>))))

  (<a id='693' tid='694' class='m'>defalias</a> <a id='695' tid='696' class='m'>&#39;</a><a id='697' tid='698' class='m'>paredit-warn</a> (<a id='699' tid='700' class='m'>if</a> (<a id='701' tid='702' class='m'>fboundp</a> <a id='703' tid='704' class='m'>&#39;</a><a id='705' tid='706' class='m'>warn</a>) <a id='707' tid='708' class='m'>&#39;</a><a id='709' tid='710' class='m'>warn</a> <a id='711' tid='712' class='m'>&#39;</a><a id='713' tid='714' class='m'>message</a>))

  (<a id='621' tid='622' class='m'>defvar</a> <a id='623' tid='624' class='m'>paredit-sexp-error-type</a>
    (<a id='625' tid='626' class='m'>with-temp-buffer</a>
      (<a id='627' tid='628' class='m'>insert</a> <a id='629' tid='630' class='m'>&quot;(&quot;</a>)
      (<a id='631' tid='632' class='m'>condition-case</a> <a id='633' tid='634' class='m'>condition</a>
          (<a id='635' tid='636' class='m'>backward-sexp</a>)
        (<a id='637' tid='638' class='m'>error</a> (<span class='d'>if</span> (<a id='639' tid='640' class='m'>eq</a> (<a id='641' tid='642' class='m'>car</a> <a id='643' tid='644' class='m'>condition</a>) <a id='645' tid='646' class='m'>&#39;</a><a id='647' tid='648' class='m'>error</a>)
                   <span class='d'>(paredit-warn &quot;%s%s%s%s&quot;
                                 &quot;Paredit is unable to discriminate&quot;
                                 &quot; S-expression parse errors from&quot;
                                 &quot; other errors. &quot;
                                 &quot; This may cause obscure problems. &quot;
                                 &quot; Please upgrade Emacs.&quot;)</span>)
               (<a id='649' tid='650' class='m'>car</a> <a id='651' tid='652' class='m'>condition</a>)))))

  (<a id='715' tid='716' class='m'>defmacro</a> <a id='717' tid='718' class='m'>paredit-handle-sexp-errors</a> (<a id='719' tid='720' class='m'>body</a> <a id='721' tid='722' class='m'>&rest</a> <a id='723' tid='724' class='m'>handler</a>)
    <a id='725' tid='726' class='m'>`</a>(<a id='727' tid='728' class='m'>condition-case</a> ()
         <a id='729' tid='730' class='m'>,</a><a id='731' tid='732' class='m'>body</a>
       (<a id='733' tid='734' class='m'>,</a><a id='735' tid='736' class='m'>paredit-sexp-error-type</a> <a id='737' tid='738' class='m'>,</a><a id='739' tid='740' class='m'>@handler</a>)))

  (<a id='741' tid='742' class='m'>put</a> <a id='743' tid='744' class='m'>&#39;</a><a id='745' tid='746' class='m'>paredit-handle-sexp-errors</a> <a id='747' tid='748' class='m'>&#39;</a><a id='749' tid='750' class='m'>lisp-indent-function</a> <a id='751' tid='752' class='m'>1</a>)

  (<a id='753' tid='754' class='m'>defmacro</a> <a id='755' tid='756' class='m'>paredit-ignore-sexp-errors</a> (<a id='757' tid='758' class='m'>&rest</a> <a id='759' tid='760' class='m'>body</a>)
    <a id='761' tid='762' class='m'>`</a>(<a id='763' tid='764' class='m'>paredit-handle-sexp-errors</a> (<a id='765' tid='766' class='m'>progn</a> <a id='767' tid='768' class='m'>,</a><a id='769' tid='770' class='m'>@body</a>)
       <a id='771' tid='772' class='m'>nil</a>))

  (<a id='773' tid='774' class='m'>put</a> <a id='775' tid='776' class='m'>&#39;</a><a id='777' tid='778' class='m'>paredit-ignore-sexp-errors</a> <a id='779' tid='780' class='m'>&#39;</a><a id='781' tid='782' class='m'>lisp-indent-function</a> <a id='783' tid='784' class='m'>0</a>)

  <a id='785' tid='786' class='m'>nil</a>)

<span class='d'>;;;; Minor Mode Definition
</span>
(<a id='4189' tid='4190' class='u'>defvar</a> <a id='4191' tid='4192' class='u'>paredit-mode-map</a> (<a id='4193' tid='4194' class='u'>make-sparse-keymap</a>)
  <a id='4195' tid='4196' class='u'>&quot;Keymap for the paredit minor mode.&quot;</a>)

(<a id='4119' tid='4120' class='u'>define-minor-mode</a> <a id='4121' tid='4122' class='u'>paredit-mode</a>
  <span class='d'>&quot;Minor mode for pseudo-structurally editing Lisp code.
\\&lt;paredit-mode-map&gt;&quot;</span>
  <a id='4123' tid='4124' class='u'>:lighter</a> <a id='4125' tid='4126' class='u'>&quot; Paredit&quot;</a>
  <a id='4127' tid='4128' class='u'>;; If we&#39;re enabling paredit-mode, the prefix to this code that
</a>  <a id='4129' tid='4130' class='u'>;; DEFINE-MINOR-MODE inserts will have already set PAREDIT-MODE to
</a>  <a id='4131' tid='4132' class='u'>;; true.  If this is the case, then first check the parentheses, and
</a>  <a id='4133' tid='4134' class='u'>;; if there are any imbalanced ones we must inhibit the activation of
</a>  <a id='4135' tid='4136' class='u'>;; paredit mode.  We skip the check, though, if the user supplied a
</a>  <a id='4137' tid='4138' class='u'>;; prefix argument interactively.
</a>  (<a id='4139' tid='4140' class='u'>if</a> (<a id='4141' tid='4142' class='u'>and</a> <a id='4143' tid='4144' class='u'>paredit-mode</a>
           (<a id='4145' tid='4146' class='u'>not</a> <a id='4147' tid='4148' class='u'>current-prefix-arg</a>))
      (<a id='4149' tid='4150' class='u'>if</a> (<a id='4151' tid='4152' class='u'>not</a> (<a id='4153' tid='4154' class='u'>fboundp</a> <a id='4155' tid='4156' class='u'>&#39;</a><a id='4157' tid='4158' class='u'>check-parens</a>))
          (<a id='4159' tid='4160' class='u'>paredit-warn</a> <a id='4161' tid='4162' class='u'>&quot;`check-parens&#39; is not defined; %s&quot;</a>
                        <a id='4163' tid='4164' class='u'>&quot;be careful of malformed S-expressions.&quot;</a>)
          (<a id='4165' tid='4166' class='u'>condition-case</a> <a id='4167' tid='4168' class='u'>condition</a>
              (<a id='4169' tid='4170' class='u'>check-parens</a>)
            (<a id='4171' tid='4172' class='u'>error</a> (<a id='4173' tid='4174' class='u'>setq</a> <a id='4175' tid='4176' class='u'>paredit-mode</a> <a id='4177' tid='4178' class='u'>nil</a>)
                   (<a id='4179' tid='4180' class='u'>signal</a> (<a id='4181' tid='4182' class='u'>car</a> <a id='4183' tid='4184' class='u'>condition</a>) (<a id='4185' tid='4186' class='u'>cdr</a> <a id='4187' tid='4188' class='u'>condition</a>)))))))

<span class='d'>;;; Old functions from when there was a different mode for emacs -nw.
</span>
(<a id='1527' tid='1528' class='u'>defun</a> <a id='1529' tid='1530' class='u'>enable-paredit-mode</a> ()
  <span class='d'>&quot;Turn on pseudo-structural editing of Lisp code.

Deprecated: use `paredit-mode&#39; instead.&quot;</span>
  (<a id='1531' tid='1532' class='u'>interactive</a>)
  (<a id='1533' tid='1534' class='u'>paredit-mode</a> <a id='1535' tid='1536' class='u'>+1</a>))

(<a id='1517' tid='1518' class='u'>defun</a> <a id='1519' tid='1520' class='u'>disable-paredit-mode</a> ()
  <span class='d'>&quot;Turn off pseudo-structural editing of Lisp code.

Deprecated: use `paredit-mode&#39; instead.&quot;</span>
  (<a id='1521' tid='1522' class='u'>interactive</a>)
  (<a id='1523' tid='1524' class='u'>paredit-mode</a> <a id='1525' tid='1526' class='u'>-1</a>))

(<a id='1957' tid='1958' class='u'>defvar</a> <a id='1959' tid='1960' class='u'>paredit-backward-delete-key</a>
  (<a id='1961' tid='1962' class='u'>xcond</a> ((<a id='1963' tid='1964' class='u'>paredit-xemacs-p</a>)    <a id='1965' tid='1966' class='u'>&quot;BS&quot;</a>)
         ((<a id='1967' tid='1968' class='u'>paredit-gnu-emacs-p</a>) <a id='1969' tid='1970' class='u'>&quot;DEL&quot;</a>)))

(<a id='2595' tid='2596' class='u'>defvar</a> <a id='2597' tid='2598' class='u'>paredit-forward-delete-keys</a>
  (<a id='2599' tid='2600' class='u'>xcond</a> ((<a id='2601' tid='2602' class='u'>paredit-xemacs-p</a>)    <a id='2603' tid='2604' class='u'>&#39;</a>(<a id='2605' tid='2606' class='u'>&quot;DEL&quot;</a>))
         ((<a id='2607' tid='2608' class='u'>paredit-gnu-emacs-p</a>) <a id='2609' tid='2610' class='u'>&#39;</a>(<a id='2611' tid='2612' class='u'>&quot;&lt;delete&gt;&quot;</a> <a id='2613' tid='2614' class='u'>&quot;&lt;deletechar&gt;&quot;</a>))))

<span class='d'>;;;; Paredit Keys
</span>
<span class='d'>;;; Separating the definition and initialization of this variable
</span><span class='d'>;;; simplifies the development of paredit, since re-evaluating DEFVAR
</span><span class='d'>;;; forms doesn&#39;t actually do anything.
</span>
(<a id='2199' tid='2200' class='u'>defvar</a> <a id='2201' tid='2202' class='u'>paredit-commands</a> <a id='2203' tid='2204' class='u'>nil</a>
  <a id='2205' tid='2206' class='u'>&quot;List of paredit commands with their keys and examples.&quot;</a>)

<span class='d'>;;; Each specifier is of the form:
</span><span class='d'>;;;   (key[s] function (example-input example-output) ...)
</span><span class='d'>;;; where key[s] is either a single string suitable for passing to KBD
</span><span class='d'>;;; or a list of such strings.  Entries in this list may also just be
</span><span class='d'>;;; strings, in which case they are headings for the next entries.
</span>
(<a id='787' tid='788' class='m'>progn</a> (<a id='789' tid='790' class='m'>setq</a> <a id='791' tid='792' class='m'>paredit-commands</a>
 <a id='793' tid='794' class='m'>`</a>(
   <span class='d'>&quot;Basic Insertion Commands&quot;</span>
   <span class='d'>(&quot;(&quot;         paredit-open-parenthesis
                (&quot;(a b |c d)&quot;
                 &quot;(a b (|) c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar (|baz\&quot; quux)&quot;))</span>
   <span class='d'>(&quot;)&quot;         paredit-close-parenthesis-and-newline
                (&quot;(defun f (x|  ))&quot;
                 &quot;(defun f (x)\n  |)&quot;)
                (&quot;; (Foo.|&quot;
                 &quot;; (Foo.)|&quot;))</span>
   <span class='d'>(&quot;M-)&quot;       paredit-close-parenthesis
                (&quot;(a b |c   )&quot; &quot;(a b c)|&quot;)
                (&quot;; Hello,| world!&quot;
                 &quot;; Hello,)| world!&quot;))</span>
   <span class='d'>(&quot;[&quot;         paredit-open-bracket
                (&quot;(a b |c d)&quot;
                 &quot;(a b [|] c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar [baz\&quot; quux)&quot;))</span>
   <span class='d'>(&quot;]&quot;         paredit-close-bracket
                (&quot;(define-key keymap [frob|  ] &#39;frobnicate)&quot;
                 &quot;(define-key keymap [frob]| &#39;frobnicate)&quot;)
                (&quot;; [Bar.|&quot;
                 &quot;; [Bar.]|&quot;))</span>
   (<a id='795' tid='796' class='m'>&quot;\&quot;&quot;</a>        <a id='797' tid='798' class='m'>paredit-doublequote</a>
                (<a id='799' tid='800' class='m'>&quot;(frob grovel |full lexical)&quot;</a>
                 <a id='801' tid='802' class='m'>&quot;(frob grovel \&quot;|\&quot; full lexical)&quot;</a>)
                (<a id='803' tid='804' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='805' tid='806' class='m'>&quot;(foo \&quot;bar \\\&quot;|baz\&quot; quux)&quot;</a>))
   (<a id='495' tid='496' class='m'>&quot;M-\&quot;&quot;</a>      <a id='497' tid='498' class='m'>paredit-meta-doublequote</a>
                (<a id='499' tid='500' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='501' tid='502' class='m'>&quot;(foo \&quot;bar baz\&quot;\n     |quux)&quot;</a>)
                (<a id='503' tid='504' class='m'>&quot;(foo |(bar #\\x \&quot;baz \\\\ quux\&quot;) zot)&quot;</a>
                 <a id='505' tid='506' class='m'>,</a>(<a id='507' tid='508' class='m'>concat</a> <a id='509' tid='510' class='m'>&quot;(foo \&quot;|(bar #\\\\x \\\&quot;baz \\\\&quot;</a>
                          <a id='511' tid='512' class='m'>&quot;\\\\ quux\\\&quot;)\&quot; zot)&quot;</a>)))
   (<a id='393' tid='394' class='m'>&quot;\\&quot;</a>        <a id='395' tid='396' class='m'>paredit-backslash</a>
                (<a id='397' tid='398' class='m'>&quot;(string #|)\n  ; Escaping character... (x)&quot;</a>
                 <a id='399' tid='400' class='m'>&quot;(string #\\x|)&quot;</a>)
                (<a id='401' tid='402' class='m'>&quot;\&quot;foo|bar\&quot;\n  ; Escaping character... (\&quot;)&quot;</a>
                 <a id='403' tid='404' class='m'>&quot;\&quot;foo\\\&quot;|bar\&quot;&quot;</a>))
   <span class='d'>(&quot;;&quot;         paredit-semicolon
                (&quot;|(frob grovel)&quot;
                 &quot;;|\n(frob grovel)&quot;)
                (&quot;(frob grovel)    |&quot;
                 &quot;(frob grovel)    ;|&quot;))</span>
   (<a id='305' tid='306' class='m'>&quot;M-;&quot;</a>       <a id='307' tid='308' class='m'>paredit-comment-dwim</a>
                (<a id='309' tid='310' class='m'>&quot;(foo |bar)   ; baz&quot;</a>
                 <a id='311' tid='312' class='m'>&quot;(foo bar)                               ; |baz&quot;</a>)
                (<a id='313' tid='314' class='m'>&quot;(frob grovel)|&quot;</a>
                 <a id='315' tid='316' class='m'>&quot;(frob grovel)                           ;|&quot;</a>)
                (<a id='317' tid='318' class='m'>&quot;    (foo bar)\n|\n    (baz quux)&quot;</a>
                 <a id='319' tid='320' class='m'>&quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;</a>)
                (<a id='321' tid='322' class='m'>&quot;    (foo bar) |(baz quux)&quot;</a>
                 <a id='323' tid='324' class='m'>&quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;</a>)
                (<a id='325' tid='326' class='m'>&quot;|(defun hello-world ...)&quot;</a>
                 <a id='327' tid='328' class='m'>&quot;;;; |\n(defun hello-world ...)&quot;</a>))

   (<a id='261' tid='262' class='m'>&quot;C-j&quot;</a>       <a id='263' tid='264' class='m'>paredit-newline</a>
                (<a id='265' tid='266' class='m'>&quot;(let ((n (frobbotz))) |(display (+ n 1)\nport))&quot;</a>
                 <a id='267' tid='268' class='m'>,</a>(<a id='269' tid='270' class='m'>concat</a> <a id='271' tid='272' class='m'>&quot;(let ((n (frobbotz)))&quot;</a>
                          <a id='273' tid='274' class='m'>&quot;\n  |(display (+ n 1)&quot;</a>
                          <a id='275' tid='276' class='m'>&quot;\n            port))&quot;</a>)))

   <span class='d'>&quot;Deleting & Killing&quot;</span>
   ((<a id='217' tid='218' class='m'>&quot;C-d&quot;</a> <a id='219' tid='220' class='m'>,</a><a id='221' tid='222' class='m'>@paredit-forward-delete-keys</a>)
                <a id='223' tid='224' class='m'>paredit-forward-delete</a>
                (<a id='225' tid='226' class='m'>&quot;(quu|x \&quot;zot\&quot;)&quot;</a> <a id='227' tid='228' class='m'>&quot;(quu| \&quot;zot\&quot;)&quot;</a>)
                (<a id='229' tid='230' class='m'>&quot;(quux |\&quot;zot\&quot;)&quot;</a>
                 <a id='231' tid='232' class='m'>&quot;(quux \&quot;|zot\&quot;)&quot;</a>
                 <a id='233' tid='234' class='m'>&quot;(quux \&quot;|ot\&quot;)&quot;</a>)
                (<a id='235' tid='236' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='237' tid='238' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='239' tid='240' class='m'>&quot;|(foo bar)&quot;</a> <a id='241' tid='242' class='m'>&quot;(|foo bar)&quot;</a>))
   (<a id='193' tid='194' class='m'>,</a><a id='195' tid='196' class='m'>paredit-backward-delete-key</a>
                <a id='197' tid='198' class='m'>paredit-backward-delete</a>
                (<a id='199' tid='200' class='m'>&quot;(\&quot;zot\&quot; q|uux)&quot;</a> <a id='201' tid='202' class='m'>&quot;(\&quot;zot\&quot; |uux)&quot;</a>)
                (<a id='203' tid='204' class='m'>&quot;(\&quot;zot\&quot;| quux)&quot;</a>
                 <a id='205' tid='206' class='m'>&quot;(\&quot;zot|\&quot; quux)&quot;</a>
                 <a id='207' tid='208' class='m'>&quot;(\&quot;zo|\&quot; quux)&quot;</a>)
                (<a id='209' tid='210' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='211' tid='212' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='213' tid='214' class='m'>&quot;(foo bar)|&quot;</a> <a id='215' tid='216' class='m'>&quot;(foo bar|)&quot;</a>))
   (<a id='173' tid='174' class='m'>&quot;C-k&quot;</a>       <a id='175' tid='176' class='m'>paredit-kill</a>
                (<a id='177' tid='178' class='m'>&quot;(foo bar)|     ; Useless comment!&quot;</a>
                 <a id='179' tid='180' class='m'>&quot;(foo bar)|&quot;</a>)
                (<a id='181' tid='182' class='m'>&quot;(|foo bar)     ; Useful comment!&quot;</a>
                 <a id='183' tid='184' class='m'>&quot;(|)     ; Useful comment!&quot;</a>)
                (<a id='185' tid='186' class='m'>&quot;|(foo bar)     ; Useless line!&quot;</a>
                 <a id='187' tid='188' class='m'>&quot;|&quot;</a>)
                (<a id='189' tid='190' class='m'>&quot;(foo \&quot;|bar baz\&quot;\n     quux)&quot;</a>
                 <a id='191' tid='192' class='m'>&quot;(foo \&quot;|\&quot;\n     quux)&quot;</a>))
   (<a id='155' tid='156' class='m'>&quot;M-d&quot;</a>       <a id='157' tid='158' class='m'>paredit-forward-kill-word</a>
                (<a id='159' tid='160' class='m'>&quot;|(foo bar)    ; baz&quot;</a>
                 <a id='161' tid='162' class='m'>&quot;(| bar)    ; baz&quot;</a>
                 <a id='163' tid='164' class='m'>&quot;(|)    ; baz&quot;</a>
                 <a id='165' tid='166' class='m'>&quot;()    ;|&quot;</a>)
                (<a id='167' tid='168' class='m'>&quot;;;;| Frobnicate\n(defun frobnicate ...)&quot;</a>
                 <a id='169' tid='170' class='m'>&quot;;;;|\n(defun frobnicate ...)&quot;</a>
                 <a id='171' tid='172' class='m'>&quot;;;;\n(| frobnicate ...)&quot;</a>))
   (<a id='135' tid='136' class='m'>,</a>(<a id='137' tid='138' class='m'>concat</a> <a id='139' tid='140' class='m'>&quot;M-&quot;</a> <a id='141' tid='142' class='m'>paredit-backward-delete-key</a>)
                <a id='143' tid='144' class='m'>paredit-backward-kill-word</a>
                (<a id='145' tid='146' class='m'>&quot;(foo bar)    ; baz\n(quux)|&quot;</a>
                 <a id='147' tid='148' class='m'>&quot;(foo bar)    ; baz\n(|)&quot;</a>
                 <a id='149' tid='150' class='m'>&quot;(foo bar)    ; |\n()&quot;</a>
                 <a id='151' tid='152' class='m'>&quot;(foo |)    ; \n()&quot;</a>
                 <a id='153' tid='154' class='m'>&quot;(|)    ; \n()&quot;</a>))

   <span class='d'>&quot;Movement & Navigation&quot;</span>
   (<a id='123' tid='124' class='m'>&quot;C-M-f&quot;</a>     <a id='125' tid='126' class='m'>paredit-forward</a>
                (<a id='127' tid='128' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>
                 <a id='129' tid='130' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>)
                (<a id='131' tid='132' class='m'>&quot;(foo (bar)|)&quot;</a>
                 <a id='133' tid='134' class='m'>&quot;(foo (bar))|&quot;</a>))
   (<a id='111' tid='112' class='m'>&quot;C-M-b&quot;</a>     <a id='113' tid='114' class='m'>paredit-backward</a>
                (<a id='115' tid='116' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>
                 <a id='117' tid='118' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>)
                (<a id='119' tid='120' class='m'>&quot;(|(foo) bar)&quot;</a>
                 <a id='121' tid='122' class='m'>&quot;|((foo) bar)&quot;</a>))
<span class='d'>;;;(&quot;C-M-u&quot;     backward-up-list)       ; These two are built-in.
</span><span class='d'>;;;(&quot;C-M-d&quot;     down-list)
</span>   <span class='d'>(&quot;C-M-p&quot;     backward-down-list)</span>     <span class='d'>; Built-in, these are FORWARD-
</span>   <span class='d'>(&quot;C-M-n&quot;     up-list)</span>                <span class='d'>; & BACKWARD-LIST, which have
</span>                                        <span class='d'>; no need given C-M-f & C-M-b.
</span>
   <span class='d'>&quot;Depth-Changing Commands&quot;</span>
   <span class='d'>(&quot;M-(&quot;       paredit-wrap-sexp
                (&quot;(foo |bar baz)&quot;
                 &quot;(foo (|bar) baz)&quot;))</span>
   <span class='d'>(&quot;M-s&quot;       paredit-splice-sexp
                (&quot;(foo (bar| baz) quux)&quot;
                 &quot;(foo bar| baz quux)&quot;))</span>
   ((<a id='101' tid='102' class='m'>&quot;M-&lt;up&gt;&quot;</a> <a id='103' tid='104' class='m'>&quot;ESC &lt;up&gt;&quot;</a>)
                <a id='105' tid='106' class='m'>paredit-splice-sexp-killing-backward</a>
                (<a id='107' tid='108' class='m'>&quot;(foo (let ((x 5)) |(sqrt n)) bar)&quot;</a>
                 <a id='109' tid='110' class='m'>&quot;(foo (sqrt n) bar)&quot;</a>))
   ((<a id='91' tid='92' class='m'>&quot;M-&lt;down&gt;&quot;</a> <a id='93' tid='94' class='m'>&quot;ESC &lt;down&gt;&quot;</a>)
                <a id='95' tid='96' class='m'>paredit-splice-sexp-killing-forward</a>
                (<a id='97' tid='98' class='m'>&quot;(a (b c| d e) f)&quot;</a>
                 <a id='99' tid='100' class='m'>&quot;(a b c f)&quot;</a>))
   (<a id='81' tid='82' class='m'>&quot;M-r&quot;</a>       <a id='83' tid='84' class='m'>paredit-raise-sexp</a>
                (<a id='85' tid='86' class='m'>&quot;(dynamic-wind in (lambda () |body) out)&quot;</a>
                 <a id='87' tid='88' class='m'>&quot;(dynamic-wind in |body out)&quot;</a>
                 <a id='89' tid='90' class='m'>&quot;|body&quot;</a>))

   <span class='d'>&quot;Barfage & Slurpage&quot;</span>
   ((<a id='67' tid='68' class='m'>&quot;C-)&quot;</a> <a id='69' tid='70' class='m'>&quot;C-&lt;right&gt;&quot;</a>)
                <a id='71' tid='72' class='m'>paredit-forward-slurp-sexp</a>
                (<a id='73' tid='74' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>
                 <a id='75' tid='76' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>)
                (<a id='77' tid='78' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='79' tid='80' class='m'>&quot;(a b ((c| d) e) f)&quot;</a>))
   ((<a id='57' tid='58' class='m'>&quot;C-}&quot;</a> <a id='59' tid='60' class='m'>&quot;C-&lt;left&gt;&quot;</a>)
                <a id='61' tid='62' class='m'>paredit-forward-barf-sexp</a>
                (<a id='63' tid='64' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>
                 <a id='65' tid='66' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>))
   ((<a id='41' tid='42' class='m'>&quot;C-(&quot;</a> <a id='43' tid='44' class='m'>&quot;C-M-&lt;left&gt;&quot;</a> <a id='45' tid='46' class='m'>&quot;ESC C-&lt;left&gt;&quot;</a>)
                <a id='47' tid='48' class='m'>paredit-backward-slurp-sexp</a>
                (<a id='49' tid='50' class='m'>&quot;(foo bar (baz| quux) zot)&quot;</a>
                 <a id='51' tid='52' class='m'>&quot;(foo (bar baz| quux) zot)&quot;</a>)
                (<a id='53' tid='54' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='55' tid='56' class='m'>&quot;(a (b (c| d)) e f)&quot;</a>))
   ((<a id='29' tid='30' class='m'>&quot;C-{&quot;</a> <a id='31' tid='32' class='m'>&quot;C-M-&lt;right&gt;&quot;</a> <a id='33' tid='34' class='m'>&quot;ESC C-&lt;right&gt;&quot;</a>)
                <a id='35' tid='36' class='m'>paredit-backward-barf-sexp</a>
                (<a id='37' tid='38' class='m'>&quot;(foo (bar baz |quux) zot)&quot;</a>
                 <a id='39' tid='40' class='m'>&quot;(foo bar (baz |quux) zot)&quot;</a>))

   <span class='d'>&quot;Miscellaneous Commands&quot;</span>
   (<a id='17' tid='18' class='m'>&quot;M-S&quot;</a>       <a id='19' tid='20' class='m'>paredit-split-sexp</a>
                (<a id='21' tid='22' class='m'>&quot;(hello| world)&quot;</a>
                 <a id='23' tid='24' class='m'>&quot;(hello)| (world)&quot;</a>)
                (<a id='25' tid='26' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>
                 <a id='27' tid='28' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>))
   (<a id='1' tid='2' class='m'>&quot;M-J&quot;</a>       <a id='3' tid='4' class='m'>paredit-join-sexps</a>
                (<a id='5' tid='6' class='m'>&quot;(hello)| (world)&quot;</a>
                 <a id='7' tid='8' class='m'>&quot;(hello| world)&quot;</a>)
                (<a id='9' tid='10' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>
                 <a id='11' tid='12' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>)
                (<a id='13' tid='14' class='m'>&quot;hello-\n|  world&quot;</a>
                 <a id='15' tid='16' class='m'>&quot;hello-|world&quot;</a>))
   <span class='d'>(&quot;C-c C-M-l&quot; paredit-recentre-on-sexp)</span>
   ))
       <a id='807' tid='808' class='m'>nil</a>)                             <span class='d'>; end of PROGN
</span>
<span class='d'>;;;;; Command Examples
</span>
(<a id='4635' tid='4636' class='u'>eval-and-compile</a>
  (<a id='4637' tid='4638' class='u'>defmacro</a> <a id='4639' tid='4640' class='u'>paredit-do-commands</a> (<a id='4641' tid='4642' class='u'>vars</a> <a id='4643' tid='4644' class='u'>string-case</a> <a id='4645' tid='4646' class='u'>&rest</a> <a id='4647' tid='4648' class='u'>body</a>)
    (<a id='4649' tid='4650' class='u'>let</a> ((<a id='4651' tid='4652' class='u'>spec</a>     (<a id='4653' tid='4654' class='u'>nth</a> <a id='4655' tid='4656' class='u'>0</a> <a id='4657' tid='4658' class='u'>vars</a>))
          (<a id='4659' tid='4660' class='u'>keys</a>     (<a id='4661' tid='4662' class='u'>nth</a> <a id='4663' tid='4664' class='u'>1</a> <a id='4665' tid='4666' class='u'>vars</a>))
          (<a id='4667' tid='4668' class='u'>fn</a>       (<a id='4669' tid='4670' class='u'>nth</a> <a id='4671' tid='4672' class='u'>2</a> <a id='4673' tid='4674' class='u'>vars</a>))
          (<a id='4675' tid='4676' class='u'>examples</a> (<a id='4677' tid='4678' class='u'>nth</a> <a id='4679' tid='4680' class='u'>3</a> <a id='4681' tid='4682' class='u'>vars</a>)))
      <a id='4683' tid='4684' class='u'>`</a>(<a id='4685' tid='4686' class='u'>dolist</a> (<a id='4687' tid='4688' class='u'>,</a><a id='4689' tid='4690' class='u'>spec</a> <a id='4691' tid='4692' class='u'>paredit-commands</a>)
         (<a id='4693' tid='4694' class='u'>if</a> (<a id='4695' tid='4696' class='u'>stringp</a> <a id='4697' tid='4698' class='u'>,</a><a id='4699' tid='4700' class='u'>spec</a>)
             <a id='4701' tid='4702' class='u'>,</a><a id='4703' tid='4704' class='u'>string-case</a>
           (<a id='4705' tid='4706' class='u'>let</a> ((<a id='4707' tid='4708' class='u'>,</a><a id='4709' tid='4710' class='u'>keys</a> (<a id='4711' tid='4712' class='u'>let</a> ((<a id='4713' tid='4714' class='u'>k</a> (<a id='4715' tid='4716' class='u'>car</a> <a id='4717' tid='4718' class='u'>,</a><a id='4719' tid='4720' class='u'>spec</a>)))
                          (<a id='4721' tid='4722' class='u'>cond</a> ((<a id='4723' tid='4724' class='u'>stringp</a> <a id='4725' tid='4726' class='u'>k</a>) (<a id='4727' tid='4728' class='u'>list</a> <a id='4729' tid='4730' class='u'>k</a>))
                                ((<a id='4731' tid='4732' class='u'>listp</a> <a id='4733' tid='4734' class='u'>k</a>) <a id='4735' tid='4736' class='u'>k</a>)
                                (<a id='4737' tid='4738' class='u'>t</a> (<a id='4739' tid='4740' class='u'>error</a> <a id='4741' tid='4742' class='u'>&quot;Invalid paredit command %s.&quot;</a>
                                          <a id='4743' tid='4744' class='u'>,</a><a id='4745' tid='4746' class='u'>spec</a>)))))
                 (<a id='4747' tid='4748' class='u'>,</a><a id='4749' tid='4750' class='u'>fn</a> (<a id='4751' tid='4752' class='u'>cadr</a> <a id='4753' tid='4754' class='u'>,</a><a id='4755' tid='4756' class='u'>spec</a>))
                 (<a id='4757' tid='4758' class='u'>,</a><a id='4759' tid='4760' class='u'>examples</a> (<a id='4761' tid='4762' class='u'>cddr</a> <a id='4763' tid='4764' class='u'>,</a><a id='4765' tid='4766' class='u'>spec</a>)))
             <a id='4767' tid='4768' class='u'>,</a><a id='4769' tid='4770' class='u'>@body</a>)))))

  (<a id='4771' tid='4772' class='u'>put</a> <a id='4773' tid='4774' class='u'>&#39;</a><a id='4775' tid='4776' class='u'>paredit-do-commands</a> <a id='4777' tid='4778' class='u'>&#39;</a><a id='4779' tid='4780' class='u'>lisp-indent-function</a> <a id='4781' tid='4782' class='u'>2</a>))

(<a id='2247' tid='2248' class='u'>defun</a> <a id='2249' tid='2250' class='u'>paredit-define-keys</a> ()
  (<a id='2251' tid='2252' class='u'>paredit-do-commands</a> (<a id='2253' tid='2254' class='u'>spec</a> <a id='2255' tid='2256' class='u'>keys</a> <a id='2257' tid='2258' class='u'>fn</a> <a id='2259' tid='2260' class='u'>examples</a>)
      <a id='2261' tid='2262' class='u'>nil</a>       <a id='2263' tid='2264' class='u'>; string case
</a>    (<a id='2265' tid='2266' class='u'>dolist</a> (<a id='2267' tid='2268' class='u'>key</a> <a id='2269' tid='2270' class='u'>keys</a>)
      (<a id='2271' tid='2272' class='u'>define-key</a> <a id='2273' tid='2274' class='u'>paredit-mode-map</a> (<a id='2275' tid='2276' class='u'>read-kbd-macro</a> <a id='2277' tid='2278' class='u'>key</a>) <a id='2279' tid='2280' class='u'>fn</a>))))

(<a id='3105' tid='3106' class='u'>defun</a> <a id='3107' tid='3108' class='u'>paredit-function-documentation</a> (<a id='3109' tid='3110' class='u'>fn</a>)
  (<a id='3111' tid='3112' class='u'>let</a> ((<a id='3113' tid='3114' class='u'>original-doc</a> (<a id='3115' tid='3116' class='u'>get</a> <a id='3117' tid='3118' class='u'>fn</a> <a id='3119' tid='3120' class='u'>&#39;</a><a id='3121' tid='3122' class='u'>paredit-original-documentation</a>))
        (<a id='3123' tid='3124' class='u'>doc</a> (<a id='3125' tid='3126' class='u'>documentation</a> <a id='3127' tid='3128' class='u'>fn</a> <a id='3129' tid='3130' class='u'>&#39;</a><a id='3131' tid='3132' class='u'>function-documentation</a>)))
    (<a id='3133' tid='3134' class='u'>or</a> <a id='3135' tid='3136' class='u'>original-doc</a>
        (<a id='3137' tid='3138' class='u'>progn</a> (<a id='3139' tid='3140' class='u'>put</a> <a id='3141' tid='3142' class='u'>fn</a> <a id='3143' tid='3144' class='u'>&#39;</a><a id='3145' tid='3146' class='u'>paredit-original-documentation</a> <a id='3147' tid='3148' class='u'>doc</a>)
               <a id='3149' tid='3150' class='u'>doc</a>))))

(<a id='1603' tid='1604' class='u'>defun</a> <a id='1605' tid='1606' class='u'>paredit-annotate-mode-with-examples</a> ()
  (<a id='1607' tid='1608' class='u'>let</a> ((<a id='1609' tid='1610' class='u'>contents</a>
         (<a id='1611' tid='1612' class='u'>list</a> (<a id='1613' tid='1614' class='u'>paredit-function-documentation</a> <a id='1615' tid='1616' class='u'>&#39;</a><a id='1617' tid='1618' class='u'>paredit-mode</a>))))
    (<a id='1619' tid='1620' class='u'>paredit-do-commands</a> (<a id='1621' tid='1622' class='u'>spec</a> <a id='1623' tid='1624' class='u'>keys</a> <a id='1625' tid='1626' class='u'>fn</a> <a id='1627' tid='1628' class='u'>examples</a>)
        (<a id='1629' tid='1630' class='u'>push</a> (<a id='1631' tid='1632' class='u'>concat</a> <a id='1633' tid='1634' class='u'>&quot;\n\n&quot;</a> <a id='1635' tid='1636' class='u'>spec</a> <a id='1637' tid='1638' class='u'>&quot;\n&quot;</a>)
              <a id='1639' tid='1640' class='u'>contents</a>)
      (<a id='1641' tid='1642' class='u'>let</a> ((<a id='1643' tid='1644' class='u'>name</a> (<a id='1645' tid='1646' class='u'>symbol-name</a> <a id='1647' tid='1648' class='u'>fn</a>)))
        (<a id='1649' tid='1650' class='u'>if</a> (<a id='1651' tid='1652' class='u'>string-match</a> (<a id='1653' tid='1654' class='u'>symbol-name</a> <a id='1655' tid='1656' class='u'>&#39;</a><a id='1657' tid='1658' class='u'>paredit-</a>) <a id='1659' tid='1660' class='u'>name</a>)
            (<a id='1661' tid='1662' class='u'>push</a> (<a id='1663' tid='1664' class='u'>concat</a> <a id='1665' tid='1666' class='u'>&quot;\n\n\\[&quot;</a> <a id='1667' tid='1668' class='u'>name</a> <a id='1669' tid='1670' class='u'>&quot;]\t&quot;</a> <a id='1671' tid='1672' class='u'>name</a>
                          (<a id='1673' tid='1674' class='u'>if</a> <a id='1675' tid='1676' class='u'>examples</a>
                              (<a id='1677' tid='1678' class='u'>mapconcat</a> (<a id='1679' tid='1680' class='u'>lambda</a> (<a id='1681' tid='1682' class='u'>example</a>)
                                           (<a id='1683' tid='1684' class='u'>concat</a>
                                            <a id='1685' tid='1686' class='u'>&quot;\n&quot;</a>
                                            (<a id='1687' tid='1688' class='u'>mapconcat</a> <a id='1689' tid='1690' class='u'>&#39;</a><a id='1691' tid='1692' class='u'>identity</a>
                                                       <a id='1693' tid='1694' class='u'>example</a>
                                                       <a id='1695' tid='1696' class='u'>&quot;\n  ---&gt;\n&quot;</a>)
                                            <a id='1697' tid='1698' class='u'>&quot;\n&quot;</a>))
                                         <a id='1699' tid='1700' class='u'>examples</a>
                                         <a id='1701' tid='1702' class='u'>&quot;&quot;</a>)
                              <a id='1703' tid='1704' class='u'>&quot;\n  (no examples)\n&quot;</a>))
                  <a id='1705' tid='1706' class='u'>contents</a>))))
    (<a id='1707' tid='1708' class='u'>put</a> <a id='1709' tid='1710' class='u'>&#39;</a><a id='1711' tid='1712' class='u'>paredit-mode</a> <a id='1713' tid='1714' class='u'>&#39;</a><a id='1715' tid='1716' class='u'>function-documentation</a>
         (<a id='1717' tid='1718' class='u'>apply</a> <a id='1719' tid='1720' class='u'>&#39;</a><a id='1721' tid='1722' class='u'>concat</a> (<a id='1723' tid='1724' class='u'>reverse</a> <a id='1725' tid='1726' class='u'>contents</a>))))
  <a id='1727' tid='1728' class='u'>;; PUT returns the huge string we just constructed, which we don&#39;t
</a>  <a id='1729' tid='1730' class='u'>;; want it to return.
</a>  <a id='1731' tid='1732' class='u'>nil</a>)

(<a id='1537' tid='1538' class='u'>defun</a> <a id='1539' tid='1540' class='u'>paredit-annotate-functions-with-examples</a> ()
  (<a id='1541' tid='1542' class='u'>paredit-do-commands</a> (<a id='1543' tid='1544' class='u'>spec</a> <a id='1545' tid='1546' class='u'>keys</a> <a id='1547' tid='1548' class='u'>fn</a> <a id='1549' tid='1550' class='u'>examples</a>)
      <a id='1551' tid='1552' class='u'>nil</a>       <a id='1553' tid='1554' class='u'>; string case
</a>    (<a id='1555' tid='1556' class='u'>put</a> <a id='1557' tid='1558' class='u'>fn</a> <a id='1559' tid='1560' class='u'>&#39;</a><a id='1561' tid='1562' class='u'>function-documentation</a>
         (<a id='1563' tid='1564' class='u'>concat</a> (<a id='1565' tid='1566' class='u'>paredit-function-documentation</a> <a id='1567' tid='1568' class='u'>fn</a>)
                 <a id='1569' tid='1570' class='u'>&quot;\n\n\\&lt;paredit-mode-map&gt;\\[&quot;</a> (<a id='1571' tid='1572' class='u'>symbol-name</a> <a id='1573' tid='1574' class='u'>fn</a>) <a id='1575' tid='1576' class='u'>&quot;]\n&quot;</a>
                 (<a id='1577' tid='1578' class='u'>mapconcat</a> (<a id='1579' tid='1580' class='u'>lambda</a> (<a id='1581' tid='1582' class='u'>example</a>)
                              (<a id='1583' tid='1584' class='u'>concat</a> <a id='1585' tid='1586' class='u'>&quot;\n&quot;</a>
                                      (<a id='1587' tid='1588' class='u'>mapconcat</a> <a id='1589' tid='1590' class='u'>&#39;</a><a id='1591' tid='1592' class='u'>identity</a>
                                                 <a id='1593' tid='1594' class='u'>example</a>
                                                 <a id='1595' tid='1596' class='u'>&quot;\n  -&gt;\n&quot;</a>)
                                      <a id='1597' tid='1598' class='u'>&quot;\n&quot;</a>))
                            <a id='1599' tid='1600' class='u'>examples</a>
                            <a id='1601' tid='1602' class='u'>&quot;&quot;</a>)))))

<a id='4783' tid='4784' class='u'>;;;;; HTML Examples
</a>
(<a id='3325' tid='3326' class='u'>defun</a> <a id='3327' tid='3328' class='u'>paredit-insert-html-examples</a> ()
  <a id='3329' tid='3330' class='u'>&quot;Insert HTML for a paredit quick reference table.&quot;</a>
  (<a id='3331' tid='3332' class='u'>interactive</a>)
  (<a id='3333' tid='3334' class='u'>let</a> ((<a id='3335' tid='3336' class='u'>insert-lines</a> (<a id='3337' tid='3338' class='u'>lambda</a> (<a id='3339' tid='3340' class='u'>&rest</a> <a id='3341' tid='3342' class='u'>lines</a>)
                        (<a id='3343' tid='3344' class='u'>mapc</a> (<a id='3345' tid='3346' class='u'>lambda</a> (<a id='3347' tid='3348' class='u'>line</a>) (<a id='3349' tid='3350' class='u'>insert</a> <a id='3351' tid='3352' class='u'>line</a>) (<a id='3353' tid='3354' class='u'>newline</a>))
                              <a id='3355' tid='3356' class='u'>lines</a>)))
        (<a id='3357' tid='3358' class='u'>html-keys</a> (<a id='3359' tid='3360' class='u'>lambda</a> (<a id='3361' tid='3362' class='u'>keys</a>)
                     (<a id='3363' tid='3364' class='u'>mapconcat</a> <a id='3365' tid='3366' class='u'>&#39;</a><a id='3367' tid='3368' class='u'>paredit-html-quote</a> <a id='3369' tid='3370' class='u'>keys</a> <a id='3371' tid='3372' class='u'>&quot;, &quot;</a>)))
        (<a id='3373' tid='3374' class='u'>html-example</a>
         (<a id='3375' tid='3376' class='u'>lambda</a> (<a id='3377' tid='3378' class='u'>example</a>)
           (<a id='3379' tid='3380' class='u'>concat</a> <a id='3381' tid='3382' class='u'>&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>
                   (<a id='3383' tid='3384' class='u'>mapconcat</a> <a id='3385' tid='3386' class='u'>&#39;</a><a id='3387' tid='3388' class='u'>paredit-html-quote</a>
                              <a id='3389' tid='3390' class='u'>example</a>
                              (<a id='3391' tid='3392' class='u'>concat</a> <a id='3393' tid='3394' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&quot;</a>
                                      <a id='3395' tid='3396' class='u'>&quot;&nbsp;&nbsp;&nbsp;&nbsp;---&gt;&quot;</a>
                                      <a id='3397' tid='3398' class='u'>&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>))
                   <a id='3399' tid='3400' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</a>)))
        (<a id='3401' tid='3402' class='u'>firstp</a> <a id='3403' tid='3404' class='u'>t</a>))
    (<a id='3405' tid='3406' class='u'>paredit-do-commands</a> (<a id='3407' tid='3408' class='u'>spec</a> <a id='3409' tid='3410' class='u'>keys</a> <a id='3411' tid='3412' class='u'>fn</a> <a id='3413' tid='3414' class='u'>examples</a>)
        (<a id='3415' tid='3416' class='u'>progn</a> (<a id='3417' tid='3418' class='u'>if</a> (<a id='3419' tid='3420' class='u'>not</a> <a id='3421' tid='3422' class='u'>firstp</a>)
                   (<a id='3423' tid='3424' class='u'>insert</a> <a id='3425' tid='3426' class='u'>&quot;&lt;/table&gt;\n&quot;</a>)
                   (<a id='3427' tid='3428' class='u'>setq</a> <a id='3429' tid='3430' class='u'>firstp</a> <a id='3431' tid='3432' class='u'>nil</a>))
               (<a id='3433' tid='3434' class='u'>funcall</a> <a id='3435' tid='3436' class='u'>insert-lines</a>
                        (<a id='3437' tid='3438' class='u'>concat</a> <a id='3439' tid='3440' class='u'>&quot;&lt;h3&gt;&quot;</a> <a id='3441' tid='3442' class='u'>spec</a> <a id='3443' tid='3444' class='u'>&quot;&lt;/h3&gt;&quot;</a>)
                        <a id='3445' tid='3446' class='u'>&quot;&lt;table border=\&quot;1\&quot; cellpadding=\&quot;1\&quot;&gt;&quot;</a>
                        <a id='3447' tid='3448' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                        <a id='3449' tid='3450' class='u'>&quot;    &lt;th&gt;Command&lt;/th&gt;&quot;</a>
                        <a id='3451' tid='3452' class='u'>&quot;    &lt;th&gt;Keys&lt;/th&gt;&quot;</a>
                        <a id='3453' tid='3454' class='u'>&quot;    &lt;th&gt;Examples&lt;/th&gt;&quot;</a>
                        <a id='3455' tid='3456' class='u'>&quot;  &lt;/tr&gt;&quot;</a>))
      (<a id='3457' tid='3458' class='u'>let</a> ((<a id='3459' tid='3460' class='u'>name</a> (<a id='3461' tid='3462' class='u'>symbol-name</a> <a id='3463' tid='3464' class='u'>fn</a>)))
        (<a id='3465' tid='3466' class='u'>if</a> (<a id='3467' tid='3468' class='u'>string-match</a> (<a id='3469' tid='3470' class='u'>symbol-name</a> <a id='3471' tid='3472' class='u'>&#39;</a><a id='3473' tid='3474' class='u'>paredit-</a>) <a id='3475' tid='3476' class='u'>name</a>)
            (<a id='3477' tid='3478' class='u'>funcall</a> <a id='3479' tid='3480' class='u'>insert-lines</a>
                     <a id='3481' tid='3482' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                     (<a id='3483' tid='3484' class='u'>concat</a> <a id='3485' tid='3486' class='u'>&quot;    &lt;td&gt;&lt;tt&gt;&quot;</a> <a id='3487' tid='3488' class='u'>name</a> <a id='3489' tid='3490' class='u'>&quot;&lt;/tt&gt;&lt;/td&gt;&quot;</a>)
                     (<a id='3491' tid='3492' class='u'>concat</a> <a id='3493' tid='3494' class='u'>&quot;    &lt;td align=\&quot;center\&quot;&gt;&quot;</a>
                             (<a id='3495' tid='3496' class='u'>funcall</a> <a id='3497' tid='3498' class='u'>html-keys</a> <a id='3499' tid='3500' class='u'>keys</a>)
                             <a id='3501' tid='3502' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     (<a id='3503' tid='3504' class='u'>concat</a> <a id='3505' tid='3506' class='u'>&quot;    &lt;td&gt;&quot;</a>
                             (<a id='3507' tid='3508' class='u'>if</a> <a id='3509' tid='3510' class='u'>examples</a>
                                 (<a id='3511' tid='3512' class='u'>mapconcat</a> <a id='3513' tid='3514' class='u'>html-example</a> <a id='3515' tid='3516' class='u'>examples</a>
                                            <a id='3517' tid='3518' class='u'>&quot;&lt;hr&gt;&quot;</a>)
                                 <a id='3519' tid='3520' class='u'>&quot;(no examples)&quot;</a>)
                             <a id='3521' tid='3522' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     <a id='3523' tid='3524' class='u'>&quot;  &lt;/tr&gt;&quot;</a>)))))
  (<a id='3525' tid='3526' class='u'>insert</a> <a id='3527' tid='3528' class='u'>&quot;&lt;/table&gt;\n&quot;</a>))

(<a id='3151' tid='3152' class='u'>defun</a> <a id='3153' tid='3154' class='u'>paredit-html-quote</a> (<a id='3155' tid='3156' class='u'>string</a>)
  (<a id='3157' tid='3158' class='u'>with-temp-buffer</a>
    (<a id='3159' tid='3160' class='u'>dotimes</a> (<a id='3161' tid='3162' class='u'>i</a> (<a id='3163' tid='3164' class='u'>length</a> <a id='3165' tid='3166' class='u'>string</a>))
      (<a id='3167' tid='3168' class='u'>insert</a> (<a id='3169' tid='3170' class='u'>let</a> ((<a id='3171' tid='3172' class='u'>c</a> (<a id='3173' tid='3174' class='u'>elt</a> <a id='3175' tid='3176' class='u'>string</a> <a id='3177' tid='3178' class='u'>i</a>)))
                (<a id='3179' tid='3180' class='u'>cond</a> ((<a id='3181' tid='3182' class='u'>eq</a> <a id='3183' tid='3184' class='u'>c</a> <a id='3185' tid='3186' class='u'>?\&lt;</a>) <a id='3187' tid='3188' class='u'>&quot;&lt;&quot;</a>)
                      ((<a id='3189' tid='3190' class='u'>eq</a> <a id='3191' tid='3192' class='u'>c</a> <a id='3193' tid='3194' class='u'>?\&gt;</a>) <a id='3195' tid='3196' class='u'>&quot;&gt;&quot;</a>)
                      ((<a id='3197' tid='3198' class='u'>eq</a> <a id='3199' tid='3200' class='u'>c</a> <a id='3201' tid='3202' class='u'>?\&</a>) <a id='3203' tid='3204' class='u'>&quot;&amp;&quot;</a>)
                      ((<a id='3205' tid='3206' class='u'>eq</a> <a id='3207' tid='3208' class='u'>c</a> <a id='3209' tid='3210' class='u'>?\&#39;</a>) <a id='3211' tid='3212' class='u'>&quot;&apos;&quot;</a>)
                      ((<a id='3213' tid='3214' class='u'>eq</a> <a id='3215' tid='3216' class='u'>c</a> <a id='3217' tid='3218' class='u'>?\&quot;</a>) <a id='3219' tid='3220' class='u'>&quot;&quot;&quot;</a>)
                      (<a id='3221' tid='3222' class='u'>t</a> <a id='3223' tid='3224' class='u'>c</a>)))))
    (<a id='3225' tid='3226' class='u'>buffer-string</a>)))

<a id='4785' tid='4786' class='u'>;;;; Delimiter Insertion
</a>
(<a id='827' tid='828' class='m'>eval-and-compile</a>
  (<a id='809' tid='810' class='m'>defun</a> <a id='811' tid='812' class='m'>paredit-conc-name</a> (<a id='813' tid='814' class='m'>&rest</a> <a id='815' tid='816' class='m'>strings</a>)
    (<a id='817' tid='818' class='m'>intern</a> (<a id='819' tid='820' class='m'>apply</a> <a id='821' tid='822' class='m'>&#39;</a><a id='823' tid='824' class='m'>concat</a> <a id='825' tid='826' class='m'>strings</a>)))

  (<a id='829' tid='830' class='m'>defmacro</a> <a id='831' tid='832' class='m'>define-paredit-pair</a> (<a id='833' tid='834' class='m'>open</a> <a id='835' tid='836' class='m'>close</a> <a id='837' tid='838' class='m'>name</a>)
    <a id='839' tid='840' class='m'>`</a>(<span class='d'>progn</span>
       (<a id='841' tid='842' class='m'>defun</a> <a id='843' tid='844' class='m'>,</a>(<a id='845' tid='846' class='m'>paredit-conc-name</a> <a id='847' tid='848' class='m'>&quot;paredit-open-&quot;</a> <a id='849' tid='850' class='m'>name</a>) (<a id='851' tid='852' class='m'>&optional</a> <a id='853' tid='854' class='m'>n</a>)
         <a id='855' tid='856' class='m'>,</a>(<a id='857' tid='858' class='m'>concat</a> <a id='859' tid='860' class='m'>&quot;Insert a balanced &quot;</a> <a id='861' tid='862' class='m'>name</a> <a id='863' tid='864' class='m'>&quot; pair.
With a prefix argument N, put the closing &quot;</a> <a id='865' tid='866' class='m'>name</a> <a id='867' tid='868' class='m'>&quot; after N
  S-expressions forward.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  &quot;</a> <a id='869' tid='870' class='m'>name</a> <a id='871' tid='872' class='m'>&quot; pair around the region.
If in a string or a comment, insert a single &quot;</a> <a id='873' tid='874' class='m'>name</a> <a id='875' tid='876' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='877' tid='878' class='m'>interactive</a> <a id='879' tid='880' class='m'>&quot;P&quot;</a>)
         (<a id='881' tid='882' class='m'>cond</a> ((<a id='883' tid='884' class='m'>or</a> (<a id='885' tid='886' class='m'>paredit-in-string-p</a>)
                    (<a id='887' tid='888' class='m'>paredit-in-comment-p</a>))
                (<a id='889' tid='890' class='m'>insert</a> <a id='891' tid='892' class='m'>,</a><a id='893' tid='894' class='m'>open</a>))
               ((<a id='895' tid='896' class='m'>not</a> (<a id='897' tid='898' class='m'>paredit-in-char-p</a>))
                (<a id='899' tid='900' class='m'>paredit-insert-pair</a> <a id='901' tid='902' class='m'>n</a> <a id='903' tid='904' class='m'>,</a><a id='905' tid='906' class='m'>open</a> <a id='907' tid='908' class='m'>,</a><a id='909' tid='910' class='m'>close</a> <a id='911' tid='912' class='m'>&#39;</a><a id='913' tid='914' class='m'>goto-char</a>))))
       (<a id='513' tid='514' class='m'>defun</a> <a id='515' tid='516' class='m'>,</a>(<a id='517' tid='518' class='m'>paredit-conc-name</a> <a id='519' tid='520' class='m'>&quot;paredit-close-&quot;</a> <a id='521' tid='522' class='m'>name</a>) ()
         <a id='523' tid='524' class='m'>,</a>(<a id='525' tid='526' class='m'>concat</a> <a id='527' tid='528' class='m'>&quot;Move past one closing delimiter and reindent.
\(Agnostic to the specific closing delimiter.)
If in a string or comment, insert a single closing &quot;</a> <a id='529' tid='530' class='m'>name</a> <a id='531' tid='532' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='533' tid='534' class='m'>interactive</a>)
         (<a id='535' tid='536' class='m'>paredit-move-past-close</a> <a id='537' tid='538' class='m'>,</a><a id='539' tid='540' class='m'>close</a>))
       (<a id='405' tid='406' class='m'>defun</a> <a id='407' tid='408' class='m'>,</a>(<a id='409' tid='410' class='m'>paredit-conc-name</a> <a id='411' tid='412' class='m'>&quot;paredit-close-&quot;</a> <a id='413' tid='414' class='m'>name</a> <a id='415' tid='416' class='m'>&quot;-and-newline&quot;</a>) ()
         <a id='417' tid='418' class='m'>,</a>(<a id='419' tid='420' class='m'>concat</a> <a id='421' tid='422' class='m'>&quot;Move past one closing delimiter, add a newline,&quot;</a>
                  <a id='423' tid='424' class='m'>&quot; and reindent.
If there was a margin comment after the closing delimiter, preserve it
  on the same line.&quot;</a>)
         (<a id='425' tid='426' class='m'>interactive</a>)
         (<a id='427' tid='428' class='m'>paredit-move-past-close-and-newline</a> <a id='429' tid='430' class='m'>,</a><a id='431' tid='432' class='m'>close</a>)))))

<span class='d'>(define-paredit-pair ?\( ?\) &quot;parenthesis&quot;)</span>
<span class='d'>(define-paredit-pair ?\[ ?\] &quot;bracket&quot;)</span>
<span class='d'>(define-paredit-pair ?\{ ?\} &quot;brace&quot;)</span>
<span class='d'>(define-paredit-pair ?\&lt; ?\&gt; &quot;brocket&quot;)</span>

(<a id='4197' tid='4198' class='u'>defun</a> <a id='4199' tid='4200' class='u'>paredit-move-past-close</a> (<a id='4201' tid='4202' class='u'>close</a>)
  (<span class='d'>cond</span> ((<a id='915' tid='916' class='m'>or</a> (<a id='917' tid='918' class='m'>paredit-in-string-p</a>)
             (<a id='919' tid='920' class='m'>paredit-in-comment-p</a>))
         (<a id='921' tid='922' class='m'>insert</a> <a id='923' tid='924' class='m'>close</a>))
        <span class='d'>((not (paredit-in-char-p))
         (paredit-move-past-close-and-reindent)
         (paredit-blink-paren-match nil))</span>))

(<a id='4203' tid='4204' class='u'>defun</a> <a id='4205' tid='4206' class='u'>paredit-move-past-close-and-newline</a> (<a id='4207' tid='4208' class='u'>close</a>)
  (<span class='d'>cond</span> <span class='d'>((or (paredit-in-string-p)
             (paredit-in-comment-p))
         (insert close))</span>
        (<span class='d'>t</span> <span class='d'>(if (paredit-in-char-p) (forward-char))</span>
           <span class='d'>(paredit-move-past-close-and-reindent)</span>
           (<a id='925' tid='926' class='m'>let</a> ((<a id='927' tid='928' class='m'>comment.point</a> (<a id='929' tid='930' class='m'>paredit-find-comment-on-line</a>)))
             (<a id='931' tid='932' class='m'>newline</a>)
             (<a id='933' tid='934' class='m'>if</a> <a id='935' tid='936' class='m'>comment.point</a>
                 (<a id='937' tid='938' class='m'>save-excursion</a>
                   (<a id='939' tid='940' class='m'>forward-line</a> <a id='941' tid='942' class='m'>-1</a>)
                   (<a id='943' tid='944' class='m'>end-of-line</a>)
                   (<a id='945' tid='946' class='m'>indent-to</a> (<a id='947' tid='948' class='m'>cdr</a> <a id='949' tid='950' class='m'>comment.point</a>))
                   (<a id='951' tid='952' class='m'>insert</a> (<a id='953' tid='954' class='m'>car</a> <a id='955' tid='956' class='m'>comment.point</a>)))))
           <span class='d'>(lisp-indent-line)</span>
           <span class='d'>(paredit-ignore-sexp-errors (indent-sexp))</span>
           <span class='d'>(paredit-blink-paren-match t)</span>)))

(<a id='2429' tid='2430' class='u'>defun</a> <a id='2431' tid='2432' class='u'>paredit-find-comment-on-line</a> ()
  <span class='d'>&quot;Find a margin comment on the current line.
If such a comment exists, delete the comment (including all leading
  whitespace) and return a cons whose car is the comment as a string
  and whose cdr is the point of the comment&#39;s initial semicolon,
  relative to the start of the line.&quot;</span>
  (<span class='d'>save-excursion</span>
    (<span class='d'>catch</span> <span class='d'>&#39;</span><span class='d'>return</span>
      (<span class='d'>while</span> <span class='d'>t</span>
        (<span class='d'>if</span> <span class='d'>(search-forward &quot;;&quot; (point-at-eol) t)</span>
            (<span class='d'>if</span> <span class='d'>(not (or (paredit-in-string-p)
                         (paredit-in-char-p)))</span>
                (<a id='957' tid='958' class='m'>let*</a> ((<a id='959' tid='960' class='m'>start</a> (<a id='961' tid='962' class='m'>progn</a> (<a id='963' tid='964' class='m'>backward-char</a>)  <span class='d'>;before semicolon
</span>                                     (<a id='965' tid='966' class='m'>point</a>)))
                       (<a id='967' tid='968' class='m'>comment</a> (<a id='969' tid='970' class='m'>buffer-substring</a> <a id='971' tid='972' class='m'>start</a>
                                                  (<a id='973' tid='974' class='m'>point-at-eol</a>))))
                  (<a id='975' tid='976' class='m'>paredit-skip-whitespace</a> <a id='977' tid='978' class='m'>nil</a> (<a id='979' tid='980' class='m'>point-at-bol</a>))
                  (<a id='981' tid='982' class='m'>delete-region</a> (<a id='983' tid='984' class='m'>point</a>) (<a id='985' tid='986' class='m'>point-at-eol</a>))
                  (<span class='d'>throw</span> <span class='d'>&#39;</span><span class='d'>return</span>
                         (<a id='987' tid='988' class='m'>cons</a> <a id='989' tid='990' class='m'>comment</a> (<a id='991' tid='992' class='m'>-</a> <a id='993' tid='994' class='m'>start</a> (<a id='995' tid='996' class='m'>point-at-bol</a>))))))
            <span class='d'>(throw &#39;return nil)</span>)))))

(<a id='3529' tid='3530' class='u'>defun</a> <a id='3531' tid='3532' class='u'>paredit-insert-pair</a> (<a id='3533' tid='3534' class='u'>n</a> <a id='3535' tid='3536' class='u'>open</a> <a id='3537' tid='3538' class='u'>close</a> <a id='3539' tid='3540' class='u'>forward</a>)
  (<a id='3541' tid='3542' class='u'>let*</a> ((<a id='3543' tid='3544' class='u'>regionp</a> (<a id='3545' tid='3546' class='u'>and</a> (<a id='3547' tid='3548' class='u'>paredit-region-active-p</a>)
                       (<a id='3549' tid='3550' class='u'>paredit-region-safe-for-insert-p</a>)))
         (<a id='3551' tid='3552' class='u'>end</a> (<a id='3553' tid='3554' class='u'>and</a> <a id='3555' tid='3556' class='u'>regionp</a>
                   (<a id='3557' tid='3558' class='u'>not</a> <a id='3559' tid='3560' class='u'>n</a>)
                   (<a id='3561' tid='3562' class='u'>prog1</a> (<a id='3563' tid='3564' class='u'>region-end</a>)
                     (<a id='3565' tid='3566' class='u'>goto-char</a> (<a id='3567' tid='3568' class='u'>region-beginning</a>))))))
    (<a id='3569' tid='3570' class='u'>let</a> ((<a id='3571' tid='3572' class='u'>spacep</a> (<a id='3573' tid='3574' class='u'>paredit-space-for-delimiter-p</a> <a id='3575' tid='3576' class='u'>nil</a> <a id='3577' tid='3578' class='u'>open</a>)))
      (<a id='3579' tid='3580' class='u'>if</a> <a id='3581' tid='3582' class='u'>spacep</a> (<a id='3583' tid='3584' class='u'>insert</a> <a id='3585' tid='3586' class='u'>&quot; &quot;</a>))
      (<a id='3587' tid='3588' class='u'>insert</a> <a id='3589' tid='3590' class='u'>open</a>)
      (<a id='3591' tid='3592' class='u'>save-excursion</a>
        <a id='3593' tid='3594' class='u'>;; Move past the desired region.
</a>        (<a id='3595' tid='3596' class='u'>cond</a> (<a id='3597' tid='3598' class='u'>n</a> (<a id='3599' tid='3600' class='u'>funcall</a> <a id='3601' tid='3602' class='u'>forward</a>
                          (<a id='3603' tid='3604' class='u'>save-excursion</a>
                            (<a id='3605' tid='3606' class='u'>forward-sexp</a> (<a id='3607' tid='3608' class='u'>prefix-numeric-value</a> <a id='3609' tid='3610' class='u'>n</a>))
                            (<a id='3611' tid='3612' class='u'>point</a>))))
              (<a id='3613' tid='3614' class='u'>regionp</a> (<a id='3615' tid='3616' class='u'>funcall</a> <a id='3617' tid='3618' class='u'>forward</a> (<a id='3619' tid='3620' class='u'>+</a> <a id='3621' tid='3622' class='u'>end</a> (<a id='3623' tid='3624' class='u'>if</a> <a id='3625' tid='3626' class='u'>spacep</a> <a id='3627' tid='3628' class='u'>2</a> <a id='3629' tid='3630' class='u'>1</a>)))))
        (<a id='3631' tid='3632' class='u'>insert</a> <a id='3633' tid='3634' class='u'>close</a>)
        (<a id='3635' tid='3636' class='u'>if</a> (<a id='3637' tid='3638' class='u'>paredit-space-for-delimiter-p</a> <a id='3639' tid='3640' class='u'>t</a> <a id='3641' tid='3642' class='u'>close</a>)
            (<a id='3643' tid='3644' class='u'>insert</a> <a id='3645' tid='3646' class='u'>&quot; &quot;</a>))))))

(<a id='4329' tid='4330' class='u'>defun</a> <a id='4331' tid='4332' class='u'>paredit-region-safe-for-insert-p</a> ()
  (<a id='4333' tid='4334' class='u'>save-excursion</a>
    (<a id='4335' tid='4336' class='u'>let</a> ((<a id='4337' tid='4338' class='u'>beginning</a> (<a id='4339' tid='4340' class='u'>region-beginning</a>))
          (<a id='4341' tid='4342' class='u'>end</a> (<a id='4343' tid='4344' class='u'>region-end</a>)))
      (<a id='4345' tid='4346' class='u'>goto-char</a> <a id='4347' tid='4348' class='u'>beginning</a>)
      (<a id='4349' tid='4350' class='u'>let*</a> ((<a id='4351' tid='4352' class='u'>beginning-state</a> (<a id='4353' tid='4354' class='u'>paredit-current-parse-state</a>))
             (<a id='4355' tid='4356' class='u'>end-state</a> (<a id='4357' tid='4358' class='u'>parse-partial-sexp</a> <a id='4359' tid='4360' class='u'>beginning</a> <a id='4361' tid='4362' class='u'>end</a>
                                            <a id='4363' tid='4364' class='u'>nil</a> <a id='4365' tid='4366' class='u'>nil</a> <a id='4367' tid='4368' class='u'>beginning-state</a>)))
        (<a id='4369' tid='4370' class='u'>and</a> (<a id='4371' tid='4372' class='u'>=</a>  (<a id='4373' tid='4374' class='u'>nth</a> <a id='4375' tid='4376' class='u'>0</a> <a id='4377' tid='4378' class='u'>beginning-state</a>)   <a id='4379' tid='4380' class='u'>; 0. depth in parens
</a>                 (<a id='4381' tid='4382' class='u'>nth</a> <a id='4383' tid='4384' class='u'>0</a> <a id='4385' tid='4386' class='u'>end-state</a>))
             (<a id='4387' tid='4388' class='u'>eq</a> (<a id='4389' tid='4390' class='u'>nth</a> <a id='4391' tid='4392' class='u'>3</a> <a id='4393' tid='4394' class='u'>beginning-state</a>)   <a id='4395' tid='4396' class='u'>; 3. non-nil if inside a
</a>                 (<a id='4397' tid='4398' class='u'>nth</a> <a id='4399' tid='4400' class='u'>3</a> <a id='4401' tid='4402' class='u'>end-state</a>))        <a id='4403' tid='4404' class='u'>;    string
</a>             (<a id='4405' tid='4406' class='u'>eq</a> (<a id='4407' tid='4408' class='u'>nth</a> <a id='4409' tid='4410' class='u'>4</a> <a id='4411' tid='4412' class='u'>beginning-state</a>)   <a id='4413' tid='4414' class='u'>; 4. comment status, yada
</a>                 (<a id='4415' tid='4416' class='u'>nth</a> <a id='4417' tid='4418' class='u'>4</a> <a id='4419' tid='4420' class='u'>end-state</a>))
             (<a id='4421' tid='4422' class='u'>eq</a> (<a id='4423' tid='4424' class='u'>nth</a> <a id='4425' tid='4426' class='u'>5</a> <a id='4427' tid='4428' class='u'>beginning-state</a>)   <a id='4429' tid='4430' class='u'>; 5. t if following char
</a>                 (<a id='4431' tid='4432' class='u'>nth</a> <a id='4433' tid='4434' class='u'>5</a> <a id='4435' tid='4436' class='u'>end-state</a>)))))))   <span class='d'>;    quote
</span>
(<a id='4477' tid='4478' class='u'>defun</a> <a id='4479' tid='4480' class='u'>paredit-space-for-delimiter-p</a> (<a id='4481' tid='4482' class='u'>endp</a> <a id='4483' tid='4484' class='u'>delimiter</a>)
  <a id='4485' tid='4486' class='u'>;; If at the buffer limit, don&#39;t insert a space.  If there is a word,
</a>  <a id='4487' tid='4488' class='u'>;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a
</a>  <a id='4489' tid='4490' class='u'>;; close when want an open the string or an open when we want to
</a>  <a id='4491' tid='4492' class='u'>;; close the string), do insert a space.
</a>  (<span class='d'>and</span> (<a id='997' tid='998' class='m'>not</a> (<a id='999' tid='1000' class='m'>if</a> <a id='1001' tid='1002' class='m'>endp</a> (<a id='1003' tid='1004' class='m'>eobp</a>) (<a id='1005' tid='1006' class='m'>bobp</a>)))
       (<a id='433' tid='434' class='m'>memq</a> (<a id='541' tid='542' class='m'>char-syntax</a> (<a id='543' tid='544' class='m'>if</a> <a id='545' tid='546' class='m'>endp</a>
                              (<a id='547' tid='548' class='m'>char-after</a>)
                              (<a id='549' tid='550' class='m'>char-before</a>)))
             (<span class='d'>list</span> <span class='d'>?w</span> <span class='d'>?_</span> <span class='d'>?\&quot;</span>
                   (<a id='435' tid='436' class='m'>let</a> ((<a id='437' tid='438' class='m'>matching</a> (<a id='439' tid='440' class='m'>matching-paren</a> <a id='441' tid='442' class='m'>delimiter</a>)))
                     (<a id='443' tid='444' class='m'>and</a> <a id='445' tid='446' class='m'>matching</a> (<a id='447' tid='448' class='m'>char-syntax</a> <a id='449' tid='450' class='m'>matching</a>)))))))

(<a id='4209' tid='4210' class='u'>defun</a> <a id='4211' tid='4212' class='u'>paredit-move-past-close-and-reindent</a> <span class='d'>()</span>
  (<span class='d'>let</span> <span class='d'>((orig (point)))</span>
    <span class='d'>(up-list)</span>
    (<a id='1007' tid='1008' class='m'>if</a> (<a id='1009' tid='1010' class='m'>catch</a> <a id='1011' tid='1012' class='m'>&#39;</a><a id='1013' tid='1014' class='m'>return</a>                  <a id='1015' tid='1016' class='m'>; This CATCH returns T if it
</a>          (<a id='1017' tid='1018' class='m'>while</a> <a id='1019' tid='1020' class='m'>t</a>                      <a id='1021' tid='1022' class='m'>; should delete leading spaces
</a>            (<a id='1023' tid='1024' class='m'>save-excursion</a>             <a id='1025' tid='1026' class='m'>; and NIL if not.
</a>              (<a id='1027' tid='1028' class='m'>let</a> ((<a id='1029' tid='1030' class='m'>before-paren</a> (<a id='1031' tid='1032' class='m'>1-</a> (<a id='1033' tid='1034' class='m'>point</a>))))
                (<a id='1035' tid='1036' class='m'>back-to-indentation</a>)
                (<a id='1037' tid='1038' class='m'>cond</a> ((<a id='1039' tid='1040' class='m'>not</a> (<a id='1041' tid='1042' class='m'>eq</a> (<a id='1043' tid='1044' class='m'>point</a>) <a id='1045' tid='1046' class='m'>before-paren</a>))
                       <a id='1047' tid='1048' class='m'>;; Can&#39;t call PAREDIT-DELETE-LEADING-WHITESPACE
</a>                       <a id='1049' tid='1050' class='m'>;; here -- we must return from SAVE-EXCURSION
</a>                       <a id='1051' tid='1052' class='m'>;; first.
</a>                       (<a id='1053' tid='1054' class='m'>throw</a> <a id='1055' tid='1056' class='m'>&#39;</a><a id='1057' tid='1058' class='m'>return</a> <a id='1059' tid='1060' class='m'>t</a>))
                      ((<a id='1061' tid='1062' class='m'>save-excursion</a> (<a id='1063' tid='1064' class='m'>forward-line</a> <a id='1065' tid='1066' class='m'>-1</a>)
                                       (<a id='1067' tid='1068' class='m'>end-of-line</a>)
                                       (<a id='1069' tid='1070' class='m'>paredit-in-comment-p</a>))
                       <span class='d'>;; Moving the closing parenthesis any further
</span>                       <a id='1071' tid='1072' class='m'>;; would put it into a comment, so we just
</a>                       <span class='d'>;; indent the closing parenthesis where it is
</span>                       <span class='d'>;; and abort the loop, telling its continuation
</span>                       <span class='d'>;; that no leading whitespace should be deleted.
</span>                       (<a id='1073' tid='1074' class='m'>lisp-indent-line</a>)
                       (<a id='1075' tid='1076' class='m'>throw</a> <a id='1077' tid='1078' class='m'>&#39;</a><a id='1079' tid='1080' class='m'>return</a> <a id='1081' tid='1082' class='m'>nil</a>))
                      (<a id='1083' tid='1084' class='m'>t</a> (<a id='1085' tid='1086' class='m'>delete-indentation</a>)))))))
        (<a id='1087' tid='1088' class='m'>paredit-delete-leading-whitespace</a>))))

(<a id='2281' tid='2282' class='u'>defun</a> <a id='2283' tid='2284' class='u'>paredit-delete-leading-whitespace</a> ()
  <span class='d'>;; This assumes that we&#39;re on the closing parenthesis already.
</span>  (<a id='2285' tid='2286' class='u'>save-excursion</a>
    (<a id='2287' tid='2288' class='u'>backward-char</a>)
    (<a id='2289' tid='2290' class='u'>while</a> (<a id='2291' tid='2292' class='u'>let</a> ((<a id='2293' tid='2294' class='u'>syn</a> (<a id='2295' tid='2296' class='u'>char-syntax</a> (<a id='2297' tid='2298' class='u'>char-before</a>))))
             (<a id='2299' tid='2300' class='u'>and</a> (<a id='2301' tid='2302' class='u'>or</a> (<a id='2303' tid='2304' class='u'>eq</a> <a id='2305' tid='2306' class='u'>syn</a> <a id='2307' tid='2308' class='u'>?\ </a>) (<a id='2309' tid='2310' class='u'>eq</a> <a id='2311' tid='2312' class='u'>syn</a> <a id='2313' tid='2314' class='u'>?-</a>))     <a id='2315' tid='2316' class='u'>; whitespace syntax
</a>                  <a id='2317' tid='2318' class='u'>;; The above line is a perfect example of why the
</a>                  <a id='2319' tid='2320' class='u'>;; following test is necessary.
</a>                  (<a id='2321' tid='2322' class='u'>not</a> (<a id='2323' tid='2324' class='u'>paredit-in-char-p</a> (<a id='2325' tid='2326' class='u'>1-</a> (<a id='2327' tid='2328' class='u'>point</a>))))))
      (<a id='2329' tid='2330' class='u'>backward-delete-char</a> <a id='2331' tid='2332' class='u'>1</a>))))

(<a id='2159' tid='2160' class='u'>defun</a> <a id='2161' tid='2162' class='u'>paredit-blink-paren-match</a> (<a id='2163' tid='2164' class='u'>another-line-p</a>)
  (<a id='2165' tid='2166' class='u'>if</a> (<a id='2167' tid='2168' class='u'>and</a> <a id='2169' tid='2170' class='u'>blink-matching-paren</a>
           (<a id='2171' tid='2172' class='u'>or</a> (<a id='2173' tid='2174' class='u'>not</a> <a id='2175' tid='2176' class='u'>show-paren-mode</a>) <a id='2177' tid='2178' class='u'>another-line-p</a>))
      (<a id='2179' tid='2180' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2181' tid='2182' class='u'>save-excursion</a>
          (<a id='2183' tid='2184' class='u'>backward-sexp</a>)
          (<a id='2185' tid='2186' class='u'>forward-sexp</a>)
          <a id='2187' tid='2188' class='u'>;; SHOW-PAREN-MODE inhibits any blinking, so we disable it
</a>          <a id='2189' tid='2190' class='u'>;; locally here.
</a>          (<a id='2191' tid='2192' class='u'>let</a> ((<a id='2193' tid='2194' class='u'>show-paren-mode</a> <a id='2195' tid='2196' class='u'>nil</a>))
            (<a id='2197' tid='2198' class='u'>blink-matching-open</a>))))))

(<a id='2333' tid='2334' class='u'>defun</a> <a id='2335' tid='2336' class='u'>paredit-doublequote</a> (<a id='2337' tid='2338' class='u'>&optional</a> <a id='2339' tid='2340' class='u'>n</a>)
  <a id='2341' tid='2342' class='u'>&quot;Insert a pair of double-quotes.
With a prefix argument N, wrap the following N S-expressions in
  double-quotes, escaping intermediate characters if necessary.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  pair of double-quotes around the region, again escaping intermediate
  characters if necessary.
Inside a comment, insert a literal double-quote.
At the end of a string, move past the closing double-quote.
In the middle of a string, insert a backslash-escaped double-quote.
If in a character literal, do nothing.  This prevents accidentally
  changing a what was in the character literal to become a meaningful
  delimiter unintentionally.&quot;</a>
  (<a id='2343' tid='2344' class='u'>interactive</a> <a id='2345' tid='2346' class='u'>&quot;P&quot;</a>)
  (<a id='2347' tid='2348' class='u'>cond</a> ((<a id='2349' tid='2350' class='u'>paredit-in-string-p</a>)
         (<a id='2351' tid='2352' class='u'>if</a> (<a id='2353' tid='2354' class='u'>eq</a> (<a id='2355' tid='2356' class='u'>cdr</a> (<a id='2357' tid='2358' class='u'>paredit-string-start+end-points</a>))
                 (<a id='2359' tid='2360' class='u'>point</a>))
             (<a id='2361' tid='2362' class='u'>forward-char</a>)             <a id='2363' tid='2364' class='u'>; We&#39;re on the closing quote.
</a>             (<a id='2365' tid='2366' class='u'>insert</a> <a id='2367' tid='2368' class='u'>?\\</a> <a id='2369' tid='2370' class='u'>?\&quot;</a> )))
        ((<a id='2371' tid='2372' class='u'>paredit-in-comment-p</a>)
         (<a id='2373' tid='2374' class='u'>insert</a> <a id='2375' tid='2376' class='u'>?\&quot;</a> ))
        ((<a id='2377' tid='2378' class='u'>not</a> (<a id='2379' tid='2380' class='u'>paredit-in-char-p</a>))
         (<a id='2381' tid='2382' class='u'>paredit-insert-pair</a> <a id='2383' tid='2384' class='u'>n</a> <a id='2385' tid='2386' class='u'>?\&quot;</a> <a id='2387' tid='2388' class='u'>?\&quot;</a> <a id='2389' tid='2390' class='u'>&#39;</a><a id='2391' tid='2392' class='u'>paredit-forward-for-quote</a>))))

(<a id='4063' tid='4064' class='u'>defun</a> <a id='4065' tid='4066' class='u'>paredit-meta-doublequote</a> (<a id='4067' tid='4068' class='u'>&optional</a> <a id='4069' tid='4070' class='u'>n</a>)
  <a id='4071' tid='4072' class='u'>&quot;Move to the end of the string, insert a newline, and indent.
If not in a string, act as `paredit-doublequote&#39;; if no prefix argument
  is specified and the region is not active or `transient-mark-mode&#39; is
  disabled, the default is to wrap one S-expression, however, not
  zero.&quot;</a>
  (<a id='4073' tid='4074' class='u'>interactive</a> <a id='4075' tid='4076' class='u'>&quot;P&quot;</a>)
  (<a id='4077' tid='4078' class='u'>if</a> (<a id='4079' tid='4080' class='u'>not</a> (<a id='4081' tid='4082' class='u'>paredit-in-string-p</a>))
      (<a id='4083' tid='4084' class='u'>paredit-doublequote</a> (<a id='4085' tid='4086' class='u'>or</a> <a id='4087' tid='4088' class='u'>n</a>
                               (<a id='4089' tid='4090' class='u'>and</a> (<a id='4091' tid='4092' class='u'>not</a> (<a id='4093' tid='4094' class='u'>paredit-region-active-p</a>))
                                    <a id='4095' tid='4096' class='u'>1</a>)))
    (<a id='4097' tid='4098' class='u'>let</a> ((<a id='4099' tid='4100' class='u'>start+end</a> (<a id='4101' tid='4102' class='u'>paredit-string-start+end-points</a>)))
      (<a id='4103' tid='4104' class='u'>goto-char</a> (<a id='4105' tid='4106' class='u'>1+</a> (<a id='4107' tid='4108' class='u'>cdr</a> <a id='4109' tid='4110' class='u'>start+end</a>)))
      (<a id='4111' tid='4112' class='u'>newline</a>)
      (<a id='4113' tid='4114' class='u'>lisp-indent-line</a>)
      (<a id='4115' tid='4116' class='u'>paredit-ignore-sexp-errors</a> (<a id='4117' tid='4118' class='u'>indent-sexp</a>)))))

(<a id='2615' tid='2616' class='u'>defun</a> <a id='2617' tid='2618' class='u'>paredit-forward-for-quote</a> (<a id='2619' tid='2620' class='u'>end</a>)
  (<a id='2621' tid='2622' class='u'>let</a> ((<a id='2623' tid='2624' class='u'>state</a> (<a id='2625' tid='2626' class='u'>paredit-current-parse-state</a>)))
    (<a id='2627' tid='2628' class='u'>while</a> (<a id='2629' tid='2630' class='u'>&lt;</a> (<a id='2631' tid='2632' class='u'>point</a>) <a id='2633' tid='2634' class='u'>end</a>)
      (<a id='2635' tid='2636' class='u'>let</a> ((<a id='2637' tid='2638' class='u'>new-state</a> (<a id='2639' tid='2640' class='u'>parse-partial-sexp</a> (<a id='2641' tid='2642' class='u'>point</a>) (<a id='2643' tid='2644' class='u'>1+</a> (<a id='2645' tid='2646' class='u'>point</a>))
                                           <a id='2647' tid='2648' class='u'>nil</a> <a id='2649' tid='2650' class='u'>nil</a> <a id='2651' tid='2652' class='u'>state</a>)))
        (<a id='2653' tid='2654' class='u'>if</a> (<a id='2655' tid='2656' class='u'>paredit-in-string-p</a> <a id='2657' tid='2658' class='u'>new-state</a>)
            (<a id='2659' tid='2660' class='u'>if</a> (<a id='2661' tid='2662' class='u'>not</a> (<a id='2663' tid='2664' class='u'>paredit-in-string-escape-p</a>))
                (<a id='2665' tid='2666' class='u'>setq</a> <a id='2667' tid='2668' class='u'>state</a> <a id='2669' tid='2670' class='u'>new-state</a>)
              <a id='2671' tid='2672' class='u'>;; Escape character: turn it into an escaped escape
</a>              <a id='2673' tid='2674' class='u'>;; character by appending another backslash.
</a>              (<a id='2675' tid='2676' class='u'>insert</a> <a id='2677' tid='2678' class='u'>?\\</a> )
              <a id='2679' tid='2680' class='u'>;; Now the point is after both escapes, and we want to
</a>              <a id='2681' tid='2682' class='u'>;; rescan from before the first one to after the second
</a>              <a id='2683' tid='2684' class='u'>;; one.
</a>              (<a id='2685' tid='2686' class='u'>setq</a> <a id='2687' tid='2688' class='u'>state</a>
                    (<a id='2689' tid='2690' class='u'>parse-partial-sexp</a> (<a id='2691' tid='2692' class='u'>-</a> (<a id='2693' tid='2694' class='u'>point</a>) <a id='2695' tid='2696' class='u'>2</a>) (<a id='2697' tid='2698' class='u'>point</a>)
                                        <a id='2699' tid='2700' class='u'>nil</a> <a id='2701' tid='2702' class='u'>nil</a> <a id='2703' tid='2704' class='u'>state</a>))
              <a id='2705' tid='2706' class='u'>;; Advance the end point, since we just inserted a new
</a>              <a id='2707' tid='2708' class='u'>;; character.
</a>              (<a id='2709' tid='2710' class='u'>setq</a> <a id='2711' tid='2712' class='u'>end</a> (<a id='2713' tid='2714' class='u'>1+</a> <a id='2715' tid='2716' class='u'>end</a>)))
          <a id='2717' tid='2718' class='u'>;; String: escape by inserting a backslash before the quote.
</a>          (<a id='2719' tid='2720' class='u'>backward-char</a>)
          (<a id='2721' tid='2722' class='u'>insert</a> <a id='2723' tid='2724' class='u'>?\\</a> )
          <a id='2725' tid='2726' class='u'>;; The point is now between the escape and the quote, and we
</a>          <a id='2727' tid='2728' class='u'>;; want to rescan from before the escape to after the quote.
</a>          (<a id='2729' tid='2730' class='u'>setq</a> <a id='2731' tid='2732' class='u'>state</a>
                (<a id='2733' tid='2734' class='u'>parse-partial-sexp</a> (<a id='2735' tid='2736' class='u'>1-</a> (<a id='2737' tid='2738' class='u'>point</a>)) (<a id='2739' tid='2740' class='u'>1+</a> (<a id='2741' tid='2742' class='u'>point</a>))
                                    <a id='2743' tid='2744' class='u'>nil</a> <a id='2745' tid='2746' class='u'>nil</a> <a id='2747' tid='2748' class='u'>state</a>))
          <a id='2749' tid='2750' class='u'>;; Advance the end point for the same reason as above.
</a>          (<a id='2751' tid='2752' class='u'>setq</a> <a id='2753' tid='2754' class='u'>end</a> (<a id='2755' tid='2756' class='u'>1+</a> <a id='2757' tid='2758' class='u'>end</a>)))))))

<span class='d'>;;;; Escape Insertion
</span>
(<a id='1733' tid='1734' class='u'>defun</a> <a id='1735' tid='1736' class='u'>paredit-backslash</a> ()
  <a id='1737' tid='1738' class='u'>&quot;Insert a backslash followed by a character to escape.&quot;</a>
  (<a id='1739' tid='1740' class='u'>interactive</a>)
  (<a id='1741' tid='1742' class='u'>insert</a> <a id='1743' tid='1744' class='u'>?\\</a> )
  <a id='1745' tid='1746' class='u'>;; This funny conditional is necessary because PAREDIT-IN-COMMENT-P
</a>  <a id='1747' tid='1748' class='u'>;; assumes that PAREDIT-IN-STRING-P already returned false; otherwise
</a>  <a id='1749' tid='1750' class='u'>;; it may give erroneous answers.
</a>  (<a id='1751' tid='1752' class='u'>if</a> (<a id='1753' tid='1754' class='u'>or</a> (<a id='1755' tid='1756' class='u'>paredit-in-string-p</a>)
          (<a id='1757' tid='1758' class='u'>not</a> (<a id='1759' tid='1760' class='u'>paredit-in-comment-p</a>)))
      (<a id='1761' tid='1762' class='u'>let</a> ((<a id='1763' tid='1764' class='u'>delp</a> <a id='1765' tid='1766' class='u'>t</a>))
        (<a id='1767' tid='1768' class='u'>unwind-protect</a> (<a id='1769' tid='1770' class='u'>setq</a> <a id='1771' tid='1772' class='u'>delp</a>
                              (<a id='1773' tid='1774' class='u'>call-interactively</a> <a id='1775' tid='1776' class='u'>&#39;</a><a id='1777' tid='1778' class='u'>paredit-escape</a>))
          <a id='1779' tid='1780' class='u'>;; We need this in an UNWIND-PROTECT so that the backlash is
</a>          <a id='1781' tid='1782' class='u'>;; left in there *only* if PAREDIT-ESCAPE return NIL normally
</a>          <a id='1783' tid='1784' class='u'>;; -- in any other case, such as the user hitting C-g or an
</a>          <a id='1785' tid='1786' class='u'>;; error occurring, we must delete the backslash to avoid
</a>          <a id='1787' tid='1788' class='u'>;; leaving a dangling escape.  (This control structure is a
</a>          <a id='1789' tid='1790' class='u'>;; crock.)
</a>          (<a id='1791' tid='1792' class='u'>if</a> <a id='1793' tid='1794' class='u'>delp</a> (<a id='1795' tid='1796' class='u'>backward-delete-char</a> <a id='1797' tid='1798' class='u'>1</a>))))))

<span class='d'>;;; This auxiliary interactive function returns true if the backslash
</span><span class='d'>;;; should be deleted and false if not.
</span>
(<a id='2393' tid='2394' class='u'>defun</a> <a id='2395' tid='2396' class='u'>paredit-escape</a> (<a id='2397' tid='2398' class='u'>char</a>)
  <a id='2399' tid='2400' class='u'>;; I&#39;m too lazy to figure out how to do this without a separate
</a>  <a id='2401' tid='2402' class='u'>;; interactive function.
</a>  (<a id='2403' tid='2404' class='u'>interactive</a> <a id='2405' tid='2406' class='u'>&quot;cEscaping character...&quot;</a>)
  (<a id='2407' tid='2408' class='u'>if</a> (<a id='2409' tid='2410' class='u'>eq</a> <a id='2411' tid='2412' class='u'>char</a> <a id='2413' tid='2414' class='u'>127</a>)                     <a id='2415' tid='2416' class='u'>; The backslash was a typo, so
</a>      <a id='2417' tid='2418' class='u'>t</a>                                 <a id='2419' tid='2420' class='u'>; the luser wants to delete it.
</a>    (<a id='2421' tid='2422' class='u'>insert</a> <a id='2423' tid='2424' class='u'>char</a>)                       <a id='2425' tid='2426' class='u'>; (Is there a better way to
</a>    <a id='2427' tid='2428' class='u'>nil</a>))                               <span class='d'>; express the rubout char?
</span>                                        <span class='d'>; ?\^? works, but ugh...)
</span>
<span class='d'>;;; The placement of this function in this file is totally random.
</span>
(<a id='4213' tid='4214' class='u'>defun</a> <a id='4215' tid='4216' class='u'>paredit-newline</a> ()
  <span class='d'>&quot;Insert a newline and indent it.
This is like `newline-and-indent&#39;, but it not only indents the line
  that the point is on but also the S-expression following the point,
  if there is one.
Move forward one character first if on an escaped character.
If in a string, just insert a literal newline.&quot;</span>
  (<a id='4217' tid='4218' class='u'>interactive</a>)
  <span class='d'>(if (paredit-in-string-p)
      (newline)
    (if (and (not (paredit-in-comment-p)) (paredit-in-char-p))
        (forward-char))
    (newline-and-indent)
    ;; Indent the following S-expression, but don&#39;t signal an error if
    ;; there&#39;s only a closing parenthesis after the point.
    (paredit-ignore-sexp-errors (indent-sexp)))</span>)

<span class='d'>;;;; Comment Insertion
</span>
(<a id='4437' tid='4438' class='u'>defun</a> <a id='4439' tid='4440' class='u'>paredit-semicolon</a> (<a id='4441' tid='4442' class='u'>&optional</a> <a id='4443' tid='4444' class='u'>n</a>)
  <span class='d'>&quot;Insert a semicolon, moving any code after the point to a new line.
If in a string, comment, or character literal, insert just a literal
  semicolon, and do not move anything to the next line.
With a prefix argument N, insert N semicolons.&quot;</span>
  <span class='d'>(interactive &quot;P&quot;)</span>
  (<span class='d'>if</span> (<span class='d'>not</span> (<span class='d'>or</span> <span class='d'>(paredit-in-string-p)</span>
               <span class='d'>(paredit-in-comment-p)</span>
               <span class='d'>(paredit-in-char-p)</span>
               <span class='d'>;; No more code on the line after the point.
</span>               (<a id='243' tid='244' class='m'>save-excursion</a>
                 (<a id='245' tid='246' class='m'>paredit-skip-whitespace</a> <a id='247' tid='248' class='m'>t</a> (<a id='249' tid='250' class='m'>point-at-eol</a>))
                 (<a id='251' tid='252' class='m'>or</a> (<a id='253' tid='254' class='m'>eolp</a>)
                     <span class='d'>;; Let the user prefix semicolons to existing
</span>                     <span class='d'>;; comments.
</span>                     (<a id='255' tid='256' class='m'>eq</a> (<a id='257' tid='258' class='m'>char-after</a>) <a id='259' tid='260' class='m'>?\;</a>)))))
      <span class='d'>;; Don&#39;t use NEWLINE-AND-INDENT, because that will delete all of
</span>      <span class='d'>;; the horizontal whitespace first, but we just want to move the
</span>      <span class='d'>;; code following the point onto the next line while preserving
</span>      <span class='d'>;; the point on this line.
</span>      <span class='d'>;++ Why indent only the line?
</span>      <span class='d'>(save-excursion (newline) (lisp-indent-line))</span>)
  <span class='d'>(insert (make-string (if n (prefix-numeric-value n) 1)
                       ?\; ))</span>)

(<a id='2207' tid='2208' class='u'>defun</a> <a id='2209' tid='2210' class='u'>paredit-comment-dwim</a> <span class='d'>(&optional arg)</span>
  <a id='2211' tid='2212' class='u'>&quot;Call the Lisp comment command you want (Do What I Mean).
This is like `comment-dwim&#39;, but it is specialized for Lisp editing.
If transient mark mode is enabled and the mark is active, comment or
  uncomment the selected region, depending on whether it was entirely
  commented not not already.
If there is already a comment on the current line, with no prefix
  argument, indent to that comment; with a prefix argument, kill that
  comment.
Otherwise, insert a comment appropriate for the context and ensure that
  any code following the comment is moved to the next line.
At the top level, where indentation is calculated to be at column 0,
  insert a triple-semicolon comment; within code, where the indentation
  is calculated to be non-zero, and on the line there is either no code
  at all or code after the point, insert a double-semicolon comment;
  and if the point is after all code on the line, insert a single-
  semicolon margin comment at `comment-column&#39;.&quot;</a>
  (<a id='2213' tid='2214' class='u'>interactive</a> <a id='2215' tid='2216' class='u'>&quot;*P&quot;</a>)
  <span class='d'>(require &#39;newcomment)</span>
  <span class='d'>(comment-normalize-vars)</span>
  <span class='d'>(cond ((paredit-region-active-p)
         (comment-or-uncomment-region (region-beginning)
                                      (region-end)
                                      arg))
        ((paredit-comment-on-line-p)
         (if arg
             (comment-kill (if (integerp arg) arg nil))
             (comment-indent)))
        (t (paredit-insert-comment)))</span>)

(<a id='2217' tid='2218' class='u'>defun</a> <a id='2219' tid='2220' class='u'>paredit-comment-on-line-p</a> ()
  (<a id='1089' tid='1090' class='m'>save-excursion</a>
    (<a id='1091' tid='1092' class='m'>beginning-of-line</a>)
    (<a id='1093' tid='1094' class='m'>let</a> ((<a id='1095' tid='1096' class='m'>comment-p</a> <a id='1097' tid='1098' class='m'>nil</a>))
      <a id='1099' tid='1100' class='m'>;; Search forward for a comment beginning.  If there is one, set
</a>      <a id='1101' tid='1102' class='m'>;; COMMENT-P to true; if not, it will be nil.
</a>      (<a id='1103' tid='1104' class='m'>while</a> (<span class='d'>progn</span> <span class='d'>(setq comment-p
                          (search-forward &quot;;&quot; (point-at-eol)
                                          ;; t -&gt; no error
                                          t))</span>
                    (<a id='1105' tid='1106' class='m'>and</a> <a id='1107' tid='1108' class='m'>comment-p</a>
                         (<a id='1109' tid='1110' class='m'>or</a> (<a id='1111' tid='1112' class='m'>paredit-in-string-p</a>)
                             (<a id='1113' tid='1114' class='m'>paredit-in-char-p</a> (<a id='1115' tid='1116' class='m'>1-</a> (<a id='1117' tid='1118' class='m'>point</a>))))))
        (<a id='1119' tid='1120' class='m'>forward-char</a>))
      <a id='1121' tid='1122' class='m'>comment-p</a>)))

(<a id='3321' tid='3322' class='u'>defun</a> <a id='3323' tid='3324' class='u'>paredit-insert-comment</a> ()
  (<a id='1123' tid='1124' class='m'>let</a> ((<a id='1125' tid='1126' class='m'>code-after-p</a>
         (<a id='1127' tid='1128' class='m'>save-excursion</a> (<a id='1129' tid='1130' class='m'>paredit-skip-whitespace</a> <a id='1131' tid='1132' class='m'>t</a> (<a id='1133' tid='1134' class='m'>point-at-eol</a>))
                         (<a id='1135' tid='1136' class='m'>not</a> (<a id='1137' tid='1138' class='m'>eolp</a>))))
        (<a id='1139' tid='1140' class='m'>code-before-p</a>
         (<a id='1141' tid='1142' class='m'>save-excursion</a> (<a id='1143' tid='1144' class='m'>paredit-skip-whitespace</a> <a id='1145' tid='1146' class='m'>nil</a> (<a id='1147' tid='1148' class='m'>point-at-bol</a>))
                         (<a id='1149' tid='1150' class='m'>not</a> (<a id='1151' tid='1152' class='m'>bolp</a>)))))
    (<span class='d'>if</span> (<a id='1153' tid='1154' class='m'>and</a> (<a id='1155' tid='1156' class='m'>bolp</a>)
             <span class='d'>;; We have to use EQ 0 here and not ZEROP because ZEROP
</span>             <span class='d'>;; signals an error if its argument is non-numeric, but
</span>             <span class='d'>;; CALCULATE-LISP-INDENT may return nil.
</span>             (<span class='d'>eq</span> (<a id='1157' tid='1158' class='m'>let</a> ((<a id='1159' tid='1160' class='m'>indent</a> (<a id='1161' tid='1162' class='m'>calculate-lisp-indent</a>)))
                   (<a id='1163' tid='1164' class='m'>if</a> (<a id='1165' tid='1166' class='m'>consp</a> <a id='1167' tid='1168' class='m'>indent</a>)
                       (<a id='1169' tid='1170' class='m'>car</a> <a id='1171' tid='1172' class='m'>indent</a>)
                     <a id='1173' tid='1174' class='m'>indent</a>))
                 <span class='d'>0</span>))
        <span class='d'>;; Top-level comment
</span>        <span class='d'>(progn (if code-after-p (save-excursion (newline)))
               (insert &quot;;;; &quot;))</span>
      <span class='d'>(if code-after-p
          ;; Code comment
          (progn (if code-before-p
                     ;++ Why NEWLINE-AND-INDENT here and not just
                     ;++ NEWLINE, or PAREDIT-NEWLINE?
                     (newline-and-indent))
                 (lisp-indent-line)
                 (insert &quot;;; &quot;)
                 ;; Move the following code.  (NEWLINE-AND-INDENT will
                 ;; delete whitespace after the comment, though, so use
                 ;; NEWLINE & LISP-INDENT-LINE manually here.)
                 (save-excursion (newline)
                                 (lisp-indent-line)))
          ;; Margin comment
          (progn (indent-to comment-column
                            1)          ; 1 -&gt; force one leading space
                 (insert ?\; )))</span>)))

<span class='d'>;;;; Character Deletion
</span>
(<a id='2503' tid='2504' class='u'>defun</a> <a id='2505' tid='2506' class='u'>paredit-forward-delete</a> <span class='d'>(&optional arg)</span>
  <span class='d'>&quot;Delete a character forward or move forward over a delimiter.
If on an opening S-expression delimiter, move forward into the
  S-expression.
If on a closing S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a prefix argument, simply delete a character forward, without
  regard for delimiter balancing.&quot;</span>
  (<a id='2507' tid='2508' class='u'>interactive</a> <a id='2509' tid='2510' class='u'>&quot;P&quot;</a>)
  (<span class='d'>cond</span> <span class='d'>((or arg (eobp))
         (delete-char 1))</span>
        <span class='d'>((paredit-in-string-p)
         (paredit-forward-delete-in-string))</span>
        <span class='d'>((paredit-in-comment-p)
         ;++ What to do here?  This could move a partial S-expression
         ;++ into a comment and thereby invalidate the file&#39;s form,
         ;++ or move random text out of a comment.
         (delete-char 1))</span>
        ((<a id='1175' tid='1176' class='m'>paredit-in-char-p</a>)            <a id='1177' tid='1178' class='m'>; Escape -- delete both chars.
</a>         (<a id='1179' tid='1180' class='m'>backward-delete-char</a> <a id='1181' tid='1182' class='m'>1</a>)
         (<a id='1183' tid='1184' class='m'>delete-char</a> <a id='1185' tid='1186' class='m'>1</a>))
        ((<a id='551' tid='552' class='m'>eq</a> (<a id='553' tid='554' class='m'>char-after</a>) <a id='555' tid='556' class='m'>?\\</a> )         <a id='557' tid='558' class='m'>; ditto
</a>         (<a id='559' tid='560' class='m'>delete-char</a> <a id='561' tid='562' class='m'>2</a>))
        ((<a id='451' tid='452' class='m'>let</a> ((<a id='453' tid='454' class='m'>syn</a> (<a id='455' tid='456' class='m'>char-syntax</a> (<a id='457' tid='458' class='m'>char-after</a>))))
           (<a id='459' tid='460' class='m'>or</a> (<a id='461' tid='462' class='m'>eq</a> <a id='463' tid='464' class='m'>syn</a> <a id='465' tid='466' class='m'>?\(</a> )
               (<a id='467' tid='468' class='m'>eq</a> <a id='469' tid='470' class='m'>syn</a> <a id='471' tid='472' class='m'>?\&quot;</a> )))
         <span class='d'>(forward-char)</span>)
        ((<a id='329' tid='330' class='m'>and</a> (<a id='331' tid='332' class='m'>not</a> (<a id='333' tid='334' class='m'>paredit-in-char-p</a> (<a id='335' tid='336' class='m'>1-</a> (<a id='337' tid='338' class='m'>point</a>))))
              (<a id='339' tid='340' class='m'>eq</a> (<a id='341' tid='342' class='m'>char-syntax</a> (<a id='343' tid='344' class='m'>char-after</a>)) <a id='345' tid='346' class='m'>?\)</a> )
              (<a id='347' tid='348' class='m'>eq</a> (<a id='349' tid='350' class='m'>char-before</a>) (<a id='351' tid='352' class='m'>matching-paren</a> (<a id='353' tid='354' class='m'>char-after</a>))))
         (<a id='355' tid='356' class='m'>backward-delete-char</a> <a id='357' tid='358' class='m'>1</a>)       <a id='359' tid='360' class='m'>; Empty list -- delete both
</a>         (<a id='361' tid='362' class='m'>delete-char</a> <a id='363' tid='364' class='m'>1</a>))               <span class='d'>;   delimiters.
</span>        <span class='d'>;; Just delete a single character, if it&#39;s not a closing
</span>        <span class='d'>;; parenthesis.  (The character literal case is already
</span>        <span class='d'>;; handled by now.)
</span>        ((<a id='277' tid='278' class='m'>not</a> (<a id='279' tid='280' class='m'>eq</a> (<a id='281' tid='282' class='m'>char-syntax</a> (<a id='283' tid='284' class='m'>char-after</a>)) <a id='285' tid='286' class='m'>?\)</a> ))
         (<a id='287' tid='288' class='m'>delete-char</a> <a id='289' tid='290' class='m'>1</a>))))

(<a id='2511' tid='2512' class='u'>defun</a> <a id='2513' tid='2514' class='u'>paredit-forward-delete-in-string</a> ()
  (<a id='2515' tid='2516' class='u'>let</a> ((<a id='2517' tid='2518' class='u'>start+end</a> (<a id='2519' tid='2520' class='u'>paredit-string-start+end-points</a>)))
    (<a id='2521' tid='2522' class='u'>cond</a> ((<a id='2523' tid='2524' class='u'>not</a> (<a id='2525' tid='2526' class='u'>eq</a> (<a id='2527' tid='2528' class='u'>point</a>) (<a id='2529' tid='2530' class='u'>cdr</a> <a id='2531' tid='2532' class='u'>start+end</a>)))
           <a id='2533' tid='2534' class='u'>;; If it&#39;s not the close-quote, it&#39;s safe to delete.  But
</a>           <a id='2535' tid='2536' class='u'>;; first handle the case that we&#39;re in a string escape.
</a>           (<a id='2537' tid='2538' class='u'>cond</a> ((<a id='2539' tid='2540' class='u'>paredit-in-string-escape-p</a>)
                  <a id='2541' tid='2542' class='u'>;; We&#39;re right after the backslash, so backward
</a>                  <a id='2543' tid='2544' class='u'>;; delete it before deleting the escaped character.
</a>                  (<a id='2545' tid='2546' class='u'>backward-delete-char</a> <a id='2547' tid='2548' class='u'>1</a>))
                 ((<a id='2549' tid='2550' class='u'>eq</a> (<a id='2551' tid='2552' class='u'>char-after</a>) <a id='2553' tid='2554' class='u'>?\\</a> )
                  <a id='2555' tid='2556' class='u'>;; If we&#39;re not in a string escape, but we are on a
</a>                  <a id='2557' tid='2558' class='u'>;; backslash, it must start the escape for the next
</a>                  <a id='2559' tid='2560' class='u'>;; character, so delete the backslash before deleting
</a>                  <a id='2561' tid='2562' class='u'>;; the next character.
</a>                  (<a id='2563' tid='2564' class='u'>delete-char</a> <a id='2565' tid='2566' class='u'>1</a>)))
           (<a id='2567' tid='2568' class='u'>delete-char</a> <a id='2569' tid='2570' class='u'>1</a>))
          ((<a id='2571' tid='2572' class='u'>eq</a> (<a id='2573' tid='2574' class='u'>1-</a> (<a id='2575' tid='2576' class='u'>point</a>)) (<a id='2577' tid='2578' class='u'>car</a> <a id='2579' tid='2580' class='u'>start+end</a>))
           <a id='2581' tid='2582' class='u'>;; If it is the close-quote, delete only if we&#39;re also right
</a>           <a id='2583' tid='2584' class='u'>;; past the open-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='2585' tid='2586' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='2587' tid='2588' class='u'>backward-delete-char</a> <a id='2589' tid='2590' class='u'>1</a>)
           (<a id='2591' tid='2592' class='u'>delete-char</a> <a id='2593' tid='2594' class='u'>1</a>)))))

(<a id='1867' tid='1868' class='u'>defun</a> <a id='1869' tid='1870' class='u'>paredit-backward-delete</a> <span class='d'>(&optional arg)</span>
  <span class='d'>&quot;Delete a character backward or move backward over a delimiter.
If on a closing S-expression delimiter, move backward into the
  S-expression.
If on an opening S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a prefix argument, simply delete a character backward, without
  regard for delimiter balancing.&quot;</span>
  (<a id='1871' tid='1872' class='u'>interactive</a> <a id='1873' tid='1874' class='u'>&quot;P&quot;</a>)
  (<span class='d'>cond</span> <span class='d'>((or arg (bobp))
         (backward-delete-char 1))</span>      <span class='d'>;++ should this untabify?
</span>        <span class='d'>((paredit-in-string-p)
         (paredit-backward-delete-in-string))</span>
        <span class='d'>((paredit-in-comment-p)
         (backward-delete-char 1))</span>
        ((<a id='1187' tid='1188' class='m'>paredit-in-char-p</a>)            <a id='1189' tid='1190' class='m'>; Escape -- delete both chars.
</a>         (<a id='1191' tid='1192' class='m'>backward-delete-char</a> <a id='1193' tid='1194' class='m'>1</a>)
         (<a id='1195' tid='1196' class='m'>delete-char</a> <a id='1197' tid='1198' class='m'>1</a>))
        ((<a id='563' tid='564' class='m'>paredit-in-char-p</a> (<a id='565' tid='566' class='m'>1-</a> (<a id='567' tid='568' class='m'>point</a>)))
         (<a id='569' tid='570' class='m'>backward-delete-char</a> <a id='571' tid='572' class='m'>2</a>))      <span class='d'>; ditto
</span>        ((<a id='473' tid='474' class='m'>let</a> ((<a id='475' tid='476' class='m'>syn</a> (<a id='477' tid='478' class='m'>char-syntax</a> (<a id='479' tid='480' class='m'>char-before</a>))))
           (<a id='481' tid='482' class='m'>or</a> (<a id='483' tid='484' class='m'>eq</a> <a id='485' tid='486' class='m'>syn</a> <a id='487' tid='488' class='m'>?\)</a> )
               (<a id='489' tid='490' class='m'>eq</a> <a id='491' tid='492' class='m'>syn</a> <a id='493' tid='494' class='m'>?\&quot;</a> )))
         <span class='d'>(backward-char)</span>)
        ((<a id='365' tid='366' class='m'>and</a> (<a id='367' tid='368' class='m'>eq</a> (<a id='369' tid='370' class='m'>char-syntax</a> (<a id='371' tid='372' class='m'>char-before</a>)) <a id='373' tid='374' class='m'>?\(</a> )
              (<a id='375' tid='376' class='m'>eq</a> (<a id='377' tid='378' class='m'>char-after</a>) (<a id='379' tid='380' class='m'>matching-paren</a> (<a id='381' tid='382' class='m'>char-before</a>))))
         (<a id='383' tid='384' class='m'>backward-delete-char</a> <a id='385' tid='386' class='m'>1</a>)       <a id='387' tid='388' class='m'>; Empty list -- delete both
</a>         (<a id='389' tid='390' class='m'>delete-char</a> <a id='391' tid='392' class='m'>1</a>))               <span class='d'>;   delimiters.
</span>        <span class='d'>;; Delete it, unless it&#39;s an opening parenthesis.  The case
</span>        <span class='d'>;; of character literals is already handled by now.
</span>        ((<a id='291' tid='292' class='m'>not</a> (<a id='293' tid='294' class='m'>eq</a> (<a id='295' tid='296' class='m'>char-syntax</a> (<a id='297' tid='298' class='m'>char-before</a>)) <a id='299' tid='300' class='m'>?\(</a> ))
         (<a id='301' tid='302' class='m'>backward-delete-char-untabify</a> <a id='303' tid='304' class='m'>1</a>))))

(<a id='1875' tid='1876' class='u'>defun</a> <a id='1877' tid='1878' class='u'>paredit-backward-delete-in-string</a> ()
  (<a id='1879' tid='1880' class='u'>let</a> ((<a id='1881' tid='1882' class='u'>start+end</a> (<a id='1883' tid='1884' class='u'>paredit-string-start+end-points</a>)))
    (<a id='1885' tid='1886' class='u'>cond</a> ((<a id='1887' tid='1888' class='u'>not</a> (<a id='1889' tid='1890' class='u'>eq</a> (<a id='1891' tid='1892' class='u'>1-</a> (<a id='1893' tid='1894' class='u'>point</a>)) (<a id='1895' tid='1896' class='u'>car</a> <a id='1897' tid='1898' class='u'>start+end</a>)))
           <a id='1899' tid='1900' class='u'>;; If it&#39;s not the open-quote, it&#39;s safe to delete.
</a>           (<a id='1901' tid='1902' class='u'>if</a> (<a id='1903' tid='1904' class='u'>paredit-in-string-escape-p</a>)
               <a id='1905' tid='1906' class='u'>;; If we&#39;re on a string escape, since we&#39;re about to
</a>               <a id='1907' tid='1908' class='u'>;; delete the backslash, we must first delete the
</a>               <a id='1909' tid='1910' class='u'>;; escaped char.
</a>               (<a id='1911' tid='1912' class='u'>delete-char</a> <a id='1913' tid='1914' class='u'>1</a>))
           (<a id='1915' tid='1916' class='u'>backward-delete-char</a> <a id='1917' tid='1918' class='u'>1</a>)
           (<a id='1919' tid='1920' class='u'>if</a> (<a id='1921' tid='1922' class='u'>paredit-in-string-escape-p</a>)
               <a id='1923' tid='1924' class='u'>;; If, after deleting a character, we find ourselves in
</a>               <a id='1925' tid='1926' class='u'>;; a string escape, we must have deleted the escaped
</a>               <a id='1927' tid='1928' class='u'>;; character, and the backslash is behind the point, so
</a>               <a id='1929' tid='1930' class='u'>;; backward delete it.
</a>               (<a id='1931' tid='1932' class='u'>backward-delete-char</a> <a id='1933' tid='1934' class='u'>1</a>)))
          ((<a id='1935' tid='1936' class='u'>eq</a> (<a id='1937' tid='1938' class='u'>point</a>) (<a id='1939' tid='1940' class='u'>cdr</a> <a id='1941' tid='1942' class='u'>start+end</a>))
           <a id='1943' tid='1944' class='u'>;; If it is the open-quote, delete only if we&#39;re also right
</a>           <a id='1945' tid='1946' class='u'>;; past the close-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='1947' tid='1948' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='1949' tid='1950' class='u'>backward-delete-char</a> <a id='1951' tid='1952' class='u'>1</a>)
           (<a id='1953' tid='1954' class='u'>delete-char</a> <a id='1955' tid='1956' class='u'>1</a>)))))

<span class='d'>;;;; Killing
</span>
(<a id='3657' tid='3658' class='u'>defun</a> <a id='3659' tid='3660' class='u'>paredit-kill</a> <span class='d'>(&optional arg)</span>
  <span class='d'>&quot;Kill a line as if with `kill-line&#39;, but respecting delimiters.
In a string, act exactly as `kill-line&#39; but do not kill past the
  closing string delimiter.
On a line with no S-expressions on it starting after the point or
  within a comment, act exactly as `kill-line&#39;.
Otherwise, kill all S-expressions that start after the point.&quot;</span>
  (<a id='3661' tid='3662' class='u'>interactive</a> <a id='3663' tid='3664' class='u'>&quot;P&quot;</a>)
  <span class='d'>(cond (arg (kill-line))
        ((paredit-in-string-p)
         (paredit-kill-line-in-string))
        ((or (paredit-in-comment-p)
             (save-excursion
               (paredit-skip-whitespace t (point-at-eol))
               (or (eq (char-after) ?\; )
                   (eolp))))
         ;** Be careful about trailing backslashes.
         (kill-line))
        (t (paredit-kill-sexps-on-line)))</span>)

(<a id='3665' tid='3666' class='u'>defun</a> <a id='3667' tid='3668' class='u'>paredit-kill-line-in-string</a> ()
  (<span class='d'>if</span> (<a id='1199' tid='1200' class='m'>save-excursion</a> (<a id='1201' tid='1202' class='m'>paredit-skip-whitespace</a> <a id='1203' tid='1204' class='m'>t</a> (<a id='1205' tid='1206' class='m'>point-at-eol</a>))
                      (<a id='1207' tid='1208' class='m'>eolp</a>))
      <span class='d'>(kill-line)</span>
    <span class='d'>(save-excursion
      ;; Be careful not to split an escape sequence.
      (if (paredit-in-string-escape-p)
          (backward-char))
      (let ((beginning (point)))
        (while (not (or (eolp)
                        (eq (char-after) ?\&quot; )))
          (forward-char)
          ;; Skip past escaped characters.
          (if (eq (char-before) ?\\ )
              (forward-char)))
        (kill-region beginning (point))))</span>))

(<a id='3669' tid='3670' class='u'>defun</a> <a id='3671' tid='3672' class='u'>paredit-kill-sexps-on-line</a> ()
  (<a id='3673' tid='3674' class='u'>if</a> (<a id='3675' tid='3676' class='u'>paredit-in-char-p</a>)               <a id='3677' tid='3678' class='u'>; Move past the \ and prefix.
</a>      (<a id='3679' tid='3680' class='u'>backward-char</a> <a id='3681' tid='3682' class='u'>2</a>))                <a id='3683' tid='3684' class='u'>; (# in Scheme/CL, ? in elisp)
</a>  (<a id='3685' tid='3686' class='u'>let</a> ((<a id='3687' tid='3688' class='u'>beginning</a> (<a id='3689' tid='3690' class='u'>point</a>))
        (<a id='3691' tid='3692' class='u'>eol</a> (<a id='3693' tid='3694' class='u'>point-at-eol</a>)))
    (<a id='3695' tid='3696' class='u'>let</a> ((<a id='3697' tid='3698' class='u'>end-of-list-p</a> (<a id='3699' tid='3700' class='u'>paredit-forward-sexps-to-kill</a> <a id='3701' tid='3702' class='u'>beginning</a> <a id='3703' tid='3704' class='u'>eol</a>)))
      <a id='3705' tid='3706' class='u'>;; If we got to the end of the list and it&#39;s on the same line,
</a>      <a id='3707' tid='3708' class='u'>;; move backward past the closing delimiter before killing.  (This
</a>      <a id='3709' tid='3710' class='u'>;; allows something like killing the whitespace in (    ).)
</a>      (<a id='3711' tid='3712' class='u'>if</a> <a id='3713' tid='3714' class='u'>end-of-list-p</a> (<a id='3715' tid='3716' class='u'>progn</a> (<a id='3717' tid='3718' class='u'>up-list</a>) (<a id='3719' tid='3720' class='u'>backward-char</a>)))
      (<a id='3721' tid='3722' class='u'>if</a> <a id='3723' tid='3724' class='u'>kill-whole-line</a>
          (<a id='3725' tid='3726' class='u'>paredit-kill-sexps-on-whole-line</a> <a id='3727' tid='3728' class='u'>beginning</a>)
        (<a id='3729' tid='3730' class='u'>kill-region</a> <a id='3731' tid='3732' class='u'>beginning</a>
                     <a id='3733' tid='3734' class='u'>;; If all of the S-expressions were on one line,
</a>                     <a id='3735' tid='3736' class='u'>;; i.e. we&#39;re still on that line after moving past
</a>                     <a id='3737' tid='3738' class='u'>;; the last one, kill the whole line, including
</a>                     <a id='3739' tid='3740' class='u'>;; any comments; otherwise just kill to the end of
</a>                     <a id='3741' tid='3742' class='u'>;; the last S-expression we found.  Be sure,
</a>                     <a id='3743' tid='3744' class='u'>;; though, not to kill any closing parentheses.
</a>                     (<a id='3745' tid='3746' class='u'>if</a> (<a id='3747' tid='3748' class='u'>and</a> (<a id='3749' tid='3750' class='u'>not</a> <a id='3751' tid='3752' class='u'>end-of-list-p</a>)
                              (<a id='3753' tid='3754' class='u'>eq</a> (<a id='3755' tid='3756' class='u'>point-at-eol</a>) <a id='3757' tid='3758' class='u'>eol</a>))
                         <a id='3759' tid='3760' class='u'>eol</a>
                         (<a id='3761' tid='3762' class='u'>point</a>)))))))

<span class='d'>;;; Please do not try to understand this code unless you have a VERY
</span><span class='d'>;;; good reason to do so.  I gave up trying to figure it out well
</span><span class='d'>;;; enough to explain it, long ago.
</span>
(<a id='2889' tid='2890' class='u'>defun</a> <a id='2891' tid='2892' class='u'>paredit-forward-sexps-to-kill</a> (<a id='2893' tid='2894' class='u'>beginning</a> <a id='2895' tid='2896' class='u'>eol</a>)
  (<a id='2897' tid='2898' class='u'>let</a> ((<a id='2899' tid='2900' class='u'>end-of-list-p</a> <a id='2901' tid='2902' class='u'>nil</a>)
        (<a id='2903' tid='2904' class='u'>firstp</a> <a id='2905' tid='2906' class='u'>t</a>))
    <a id='2907' tid='2908' class='u'>;; Move to the end of the last S-expression that started on this
</a>    <a id='2909' tid='2910' class='u'>;; line, or to the closing delimiter if the last S-expression in
</a>    <a id='2911' tid='2912' class='u'>;; this list is on the line.
</a>    (<a id='2913' tid='2914' class='u'>catch</a> <a id='2915' tid='2916' class='u'>&#39;</a><a id='2917' tid='2918' class='u'>return</a>
      (<a id='2919' tid='2920' class='u'>while</a> <a id='2921' tid='2922' class='u'>t</a>
        <a id='2923' tid='2924' class='u'>;; This and the `kill-whole-line&#39; business below fix a bug that
</a>        <a id='2925' tid='2926' class='u'>;; inhibited any S-expression at the very end of the buffer
</a>        <a id='2927' tid='2928' class='u'>;; (with no trailing newline) from being deleted.  It&#39;s a
</a>        <a id='2929' tid='2930' class='u'>;; bizarre fix that I ought to document at some point, but I am
</a>        <a id='2931' tid='2932' class='u'>;; too busy at the moment to do so.
</a>        (<a id='2933' tid='2934' class='u'>if</a> (<a id='2935' tid='2936' class='u'>and</a> <a id='2937' tid='2938' class='u'>kill-whole-line</a> (<a id='2939' tid='2940' class='u'>eobp</a>)) (<a id='2941' tid='2942' class='u'>throw</a> <a id='2943' tid='2944' class='u'>&#39;</a><a id='2945' tid='2946' class='u'>return</a> <a id='2947' tid='2948' class='u'>nil</a>))
        (<a id='2949' tid='2950' class='u'>save-excursion</a>
          (<a id='2951' tid='2952' class='u'>paredit-handle-sexp-errors</a> (<a id='2953' tid='2954' class='u'>forward-sexp</a>)
            (<a id='2955' tid='2956' class='u'>up-list</a>)
            (<a id='2957' tid='2958' class='u'>setq</a> <a id='2959' tid='2960' class='u'>end-of-list-p</a> (<a id='2961' tid='2962' class='u'>eq</a> (<a id='2963' tid='2964' class='u'>point-at-eol</a>) <a id='2965' tid='2966' class='u'>eol</a>))
            (<a id='2967' tid='2968' class='u'>throw</a> <a id='2969' tid='2970' class='u'>&#39;</a><a id='2971' tid='2972' class='u'>return</a> <a id='2973' tid='2974' class='u'>nil</a>))
          (<a id='2975' tid='2976' class='u'>if</a> (<a id='2977' tid='2978' class='u'>or</a> (<a id='2979' tid='2980' class='u'>and</a> (<a id='2981' tid='2982' class='u'>not</a> <a id='2983' tid='2984' class='u'>firstp</a>)
                       (<a id='2985' tid='2986' class='u'>not</a> <a id='2987' tid='2988' class='u'>kill-whole-line</a>)
                       (<a id='2989' tid='2990' class='u'>eobp</a>))
                  (<a id='2991' tid='2992' class='u'>paredit-handle-sexp-errors</a>
                      (<a id='2993' tid='2994' class='u'>progn</a> (<a id='2995' tid='2996' class='u'>backward-sexp</a>) <a id='2997' tid='2998' class='u'>nil</a>)
                    <a id='2999' tid='3000' class='u'>t</a>)
                  (<a id='3001' tid='3002' class='u'>not</a> (<a id='3003' tid='3004' class='u'>eq</a> (<a id='3005' tid='3006' class='u'>point-at-eol</a>) <a id='3007' tid='3008' class='u'>eol</a>)))
              (<a id='3009' tid='3010' class='u'>throw</a> <a id='3011' tid='3012' class='u'>&#39;</a><a id='3013' tid='3014' class='u'>return</a> <a id='3015' tid='3016' class='u'>nil</a>)))
        (<a id='3017' tid='3018' class='u'>forward-sexp</a>)
        (<a id='3019' tid='3020' class='u'>if</a> (<a id='3021' tid='3022' class='u'>and</a> <a id='3023' tid='3024' class='u'>firstp</a>
                 (<a id='3025' tid='3026' class='u'>not</a> <a id='3027' tid='3028' class='u'>kill-whole-line</a>)
                 (<a id='3029' tid='3030' class='u'>eobp</a>))
            (<a id='3031' tid='3032' class='u'>throw</a> <a id='3033' tid='3034' class='u'>&#39;</a><a id='3035' tid='3036' class='u'>return</a> <a id='3037' tid='3038' class='u'>nil</a>))
        (<a id='3039' tid='3040' class='u'>setq</a> <a id='3041' tid='3042' class='u'>firstp</a> <a id='3043' tid='3044' class='u'>nil</a>)))
    <a id='3045' tid='3046' class='u'>end-of-list-p</a>))

(<a id='3763' tid='3764' class='u'>defun</a> <a id='3765' tid='3766' class='u'>paredit-kill-sexps-on-whole-line</a> (<a id='3767' tid='3768' class='u'>beginning</a>)
  (<a id='3769' tid='3770' class='u'>kill-region</a> <a id='3771' tid='3772' class='u'>beginning</a>
               (<a id='3773' tid='3774' class='u'>or</a> (<a id='3775' tid='3776' class='u'>save-excursion</a>     <a id='3777' tid='3778' class='u'>; Delete trailing indentation...
</a>                     (<a id='3779' tid='3780' class='u'>paredit-skip-whitespace</a> <a id='3781' tid='3782' class='u'>t</a>)
                     (<a id='3783' tid='3784' class='u'>and</a> (<a id='3785' tid='3786' class='u'>not</a> (<a id='3787' tid='3788' class='u'>eq</a> (<a id='3789' tid='3790' class='u'>char-after</a>) <a id='3791' tid='3792' class='u'>?\;</a> ))
                          (<a id='3793' tid='3794' class='u'>point</a>)))
                   <a id='3795' tid='3796' class='u'>;; ...or just use the point past the newline, if
</a>                   <a id='3797' tid='3798' class='u'>;; we encounter a comment.
</a>                   (<a id='3799' tid='3800' class='u'>point-at-eol</a>)))
  (<a id='3801' tid='3802' class='u'>cond</a> ((<a id='3803' tid='3804' class='u'>save-excursion</a> (<a id='3805' tid='3806' class='u'>paredit-skip-whitespace</a> <a id='3807' tid='3808' class='u'>nil</a> (<a id='3809' tid='3810' class='u'>point-at-bol</a>))
                         (<a id='3811' tid='3812' class='u'>bolp</a>))
         <a id='3813' tid='3814' class='u'>;; Nothing but indentation before the point, so indent it.
</a>         (<a id='3815' tid='3816' class='u'>lisp-indent-line</a>))
        ((<a id='3817' tid='3818' class='u'>eobp</a>) <a id='3819' tid='3820' class='u'>nil</a>)       <a id='3821' tid='3822' class='u'>; Protect the CHAR-SYNTAX below against NIL.
</a>        <a id='3823' tid='3824' class='u'>;; Insert a space to avoid invalid joining if necessary.
</a>        ((<a id='3825' tid='3826' class='u'>let</a> ((<a id='3827' tid='3828' class='u'>syn-before</a> (<a id='3829' tid='3830' class='u'>char-syntax</a> (<a id='3831' tid='3832' class='u'>char-before</a>)))
               (<a id='3833' tid='3834' class='u'>syn-after</a>  (<a id='3835' tid='3836' class='u'>char-syntax</a> (<a id='3837' tid='3838' class='u'>char-after</a>))))
           (<a id='3839' tid='3840' class='u'>or</a> (<a id='3841' tid='3842' class='u'>and</a> (<a id='3843' tid='3844' class='u'>eq</a> <a id='3845' tid='3846' class='u'>syn-before</a> <a id='3847' tid='3848' class='u'>?\)</a> )            <a id='3849' tid='3850' class='u'>; Separate opposing
</a>                    (<a id='3851' tid='3852' class='u'>eq</a> <a id='3853' tid='3854' class='u'>syn-after</a>  <a id='3855' tid='3856' class='u'>?\(</a> ))           <a id='3857' tid='3858' class='u'>;   parentheses,
</a>               (<a id='3859' tid='3860' class='u'>and</a> (<a id='3861' tid='3862' class='u'>eq</a> <a id='3863' tid='3864' class='u'>syn-before</a> <a id='3865' tid='3866' class='u'>?\&quot;</a> )            <a id='3867' tid='3868' class='u'>; string delimiter
</a>                    (<a id='3869' tid='3870' class='u'>eq</a> <a id='3871' tid='3872' class='u'>syn-after</a>  <a id='3873' tid='3874' class='u'>?\&quot;</a> ))           <a id='3875' tid='3876' class='u'>;   pairs,
</a>               (<a id='3877' tid='3878' class='u'>and</a> (<a id='3879' tid='3880' class='u'>memq</a> <a id='3881' tid='3882' class='u'>syn-before</a> <a id='3883' tid='3884' class='u'>&#39;</a>(<a id='3885' tid='3886' class='u'>?_</a> <a id='3887' tid='3888' class='u'>?w</a>))      <a id='3889' tid='3890' class='u'>; or word or symbol
</a>                    (<a id='3891' tid='3892' class='u'>memq</a> <a id='3893' tid='3894' class='u'>syn-after</a>  <a id='3895' tid='3896' class='u'>&#39;</a>(<a id='3897' tid='3898' class='u'>?_</a> <a id='3899' tid='3900' class='u'>?w</a>)))))   <a id='3901' tid='3902' class='u'>;   constituents.
</a>         (<a id='3903' tid='3904' class='u'>insert</a> <a id='3905' tid='3906' class='u'>&quot; &quot;</a>))))

<span class='d'>;;;;; Killing Words
</span>
<span class='d'>;;; This is tricky and asymmetrical because backward parsing is
</span><span class='d'>;;; extraordinarily difficult or impossible, so we have to implement
</span><span class='d'>;;; killing in both directions by parsing forward.
</span>
(<a id='2759' tid='2760' class='u'>defun</a> <a id='2761' tid='2762' class='u'>paredit-forward-kill-word</a> ()
  <a id='2763' tid='2764' class='u'>&quot;Kill a word forward, skipping over intervening delimiters.&quot;</a>
  (<a id='2765' tid='2766' class='u'>interactive</a>)
  (<a id='2767' tid='2768' class='u'>let</a> ((<a id='2769' tid='2770' class='u'>beginning</a> (<a id='2771' tid='2772' class='u'>point</a>)))
    (<a id='2773' tid='2774' class='u'>skip-syntax-forward</a> <a id='2775' tid='2776' class='u'>&quot; -&quot;</a>)
    (<a id='2777' tid='2778' class='u'>let*</a> ((<a id='2779' tid='2780' class='u'>parse-state</a> (<a id='2781' tid='2782' class='u'>paredit-current-parse-state</a>))
           (<a id='2783' tid='2784' class='u'>state</a> (<a id='2785' tid='2786' class='u'>paredit-kill-word-state</a> <a id='2787' tid='2788' class='u'>parse-state</a> <a id='2789' tid='2790' class='u'>&#39;</a><a id='2791' tid='2792' class='u'>char-after</a>)))
      (<a id='2793' tid='2794' class='u'>while</a> (<a id='2795' tid='2796' class='u'>not</a> (<a id='2797' tid='2798' class='u'>or</a> (<a id='2799' tid='2800' class='u'>eobp</a>)
                      (<a id='2801' tid='2802' class='u'>eq</a> <a id='2803' tid='2804' class='u'>?w</a> (<a id='2805' tid='2806' class='u'>char-syntax</a> (<a id='2807' tid='2808' class='u'>char-after</a>)))))
        (<a id='2809' tid='2810' class='u'>setq</a> <a id='2811' tid='2812' class='u'>parse-state</a>
              (<a id='2813' tid='2814' class='u'>progn</a> (<a id='2815' tid='2816' class='u'>forward-char</a> <a id='2817' tid='2818' class='u'>1</a>) (<a id='2819' tid='2820' class='u'>paredit-current-parse-state</a>))
<a id='2821' tid='2822' class='u'>;;               (parse-partial-sexp (point) (1+ (point))
</a><a id='2823' tid='2824' class='u'>;;                                   nil nil parse-state)
</a>              )
        (<a id='2825' tid='2826' class='u'>let*</a> ((<a id='2827' tid='2828' class='u'>old-state</a> <a id='2829' tid='2830' class='u'>state</a>)
               (<a id='2831' tid='2832' class='u'>new-state</a>
                (<a id='2833' tid='2834' class='u'>paredit-kill-word-state</a> <a id='2835' tid='2836' class='u'>parse-state</a> <a id='2837' tid='2838' class='u'>&#39;</a><a id='2839' tid='2840' class='u'>char-after</a>)))
          (<a id='2841' tid='2842' class='u'>cond</a> ((<a id='2843' tid='2844' class='u'>not</a> (<a id='2845' tid='2846' class='u'>eq</a> <a id='2847' tid='2848' class='u'>old-state</a> <a id='2849' tid='2850' class='u'>new-state</a>))
                 (<a id='2851' tid='2852' class='u'>setq</a> <a id='2853' tid='2854' class='u'>parse-state</a>
                       (<a id='2855' tid='2856' class='u'>paredit-kill-word-hack</a> <a id='2857' tid='2858' class='u'>old-state</a>
                                               <a id='2859' tid='2860' class='u'>new-state</a>
                                               <a id='2861' tid='2862' class='u'>parse-state</a>))
                 (<a id='2863' tid='2864' class='u'>setq</a> <a id='2865' tid='2866' class='u'>state</a>
                       (<a id='2867' tid='2868' class='u'>paredit-kill-word-state</a> <a id='2869' tid='2870' class='u'>parse-state</a>
                                                <a id='2871' tid='2872' class='u'>&#39;</a><a id='2873' tid='2874' class='u'>char-after</a>))
                 (<a id='2875' tid='2876' class='u'>setq</a> <a id='2877' tid='2878' class='u'>beginning</a> (<a id='2879' tid='2880' class='u'>point</a>)))))))
    (<a id='2881' tid='2882' class='u'>goto-char</a> <a id='2883' tid='2884' class='u'>beginning</a>)
    (<a id='2885' tid='2886' class='u'>kill-word</a> <a id='2887' tid='2888' class='u'>1</a>)))

(<a id='1971' tid='1972' class='u'>defun</a> <a id='1973' tid='1974' class='u'>paredit-backward-kill-word</a> ()
  <a id='1975' tid='1976' class='u'>&quot;Kill a word backward, skipping over any intervening delimiters.&quot;</a>
  (<a id='1977' tid='1978' class='u'>interactive</a>)
  (<a id='1979' tid='1980' class='u'>if</a> (<a id='1981' tid='1982' class='u'>not</a> (<a id='1983' tid='1984' class='u'>or</a> (<a id='1985' tid='1986' class='u'>bobp</a>)
               (<a id='1987' tid='1988' class='u'>eq</a> (<a id='1989' tid='1990' class='u'>char-syntax</a> (<a id='1991' tid='1992' class='u'>char-before</a>)) <a id='1993' tid='1994' class='u'>?w</a>)))
      (<a id='1995' tid='1996' class='u'>let</a> ((<a id='1997' tid='1998' class='u'>end</a> (<a id='1999' tid='2000' class='u'>point</a>)))
        (<a id='2001' tid='2002' class='u'>backward-word</a> <a id='2003' tid='2004' class='u'>1</a>)
        (<a id='2005' tid='2006' class='u'>forward-word</a> <a id='2007' tid='2008' class='u'>1</a>)
        (<a id='2009' tid='2010' class='u'>goto-char</a> (<a id='2011' tid='2012' class='u'>min</a> <a id='2013' tid='2014' class='u'>end</a> (<a id='2015' tid='2016' class='u'>point</a>)))
        (<a id='2017' tid='2018' class='u'>let*</a> ((<a id='2019' tid='2020' class='u'>parse-state</a> (<a id='2021' tid='2022' class='u'>paredit-current-parse-state</a>))
               (<a id='2023' tid='2024' class='u'>state</a>
                (<a id='2025' tid='2026' class='u'>paredit-kill-word-state</a> <a id='2027' tid='2028' class='u'>parse-state</a> <a id='2029' tid='2030' class='u'>&#39;</a><a id='2031' tid='2032' class='u'>char-before</a>)))
          (<a id='2033' tid='2034' class='u'>while</a> (<a id='2035' tid='2036' class='u'>and</a> (<a id='2037' tid='2038' class='u'>&lt;</a> (<a id='2039' tid='2040' class='u'>point</a>) <a id='2041' tid='2042' class='u'>end</a>)
                      (<a id='2043' tid='2044' class='u'>progn</a>
                        (<a id='2045' tid='2046' class='u'>setq</a> <a id='2047' tid='2048' class='u'>parse-state</a>
                              (<a id='2049' tid='2050' class='u'>parse-partial-sexp</a> (<a id='2051' tid='2052' class='u'>point</a>) (<a id='2053' tid='2054' class='u'>1+</a> (<a id='2055' tid='2056' class='u'>point</a>))
                                                  <a id='2057' tid='2058' class='u'>nil</a> <a id='2059' tid='2060' class='u'>nil</a> <a id='2061' tid='2062' class='u'>parse-state</a>))
                        (<a id='2063' tid='2064' class='u'>or</a> (<a id='2065' tid='2066' class='u'>eq</a> <a id='2067' tid='2068' class='u'>state</a>
                                (<a id='2069' tid='2070' class='u'>paredit-kill-word-state</a> <a id='2071' tid='2072' class='u'>parse-state</a>
                                                         <a id='2073' tid='2074' class='u'>&#39;</a><a id='2075' tid='2076' class='u'>char-before</a>))
                            (<a id='2077' tid='2078' class='u'>progn</a> (<a id='2079' tid='2080' class='u'>backward-char</a> <a id='2081' tid='2082' class='u'>1</a>) <a id='2083' tid='2084' class='u'>nil</a>)))))
          (<a id='2085' tid='2086' class='u'>if</a> (<a id='2087' tid='2088' class='u'>and</a> (<a id='2089' tid='2090' class='u'>eq</a> <a id='2091' tid='2092' class='u'>state</a> <a id='2093' tid='2094' class='u'>&#39;</a><a id='2095' tid='2096' class='u'>comment</a>)
                   (<a id='2097' tid='2098' class='u'>eq</a> <a id='2099' tid='2100' class='u'>?\#</a> (<a id='2101' tid='2102' class='u'>char-after</a> (<a id='2103' tid='2104' class='u'>point</a>)))
                   (<a id='2105' tid='2106' class='u'>eq</a> <a id='2107' tid='2108' class='u'>?\|</a> (<a id='2109' tid='2110' class='u'>char-before</a> (<a id='2111' tid='2112' class='u'>point</a>))))
              (<a id='2113' tid='2114' class='u'>backward-char</a> <a id='2115' tid='2116' class='u'>1</a>)))))
  (<a id='2117' tid='2118' class='u'>backward-kill-word</a> <a id='2119' tid='2120' class='u'>1</a>))

<span class='d'>;;; Word-Killing Auxiliaries
</span>
(<a id='4013' tid='4014' class='u'>defun</a> <a id='4015' tid='4016' class='u'>paredit-kill-word-state</a> (<a id='4017' tid='4018' class='u'>parse-state</a> <a id='4019' tid='4020' class='u'>adjacent-char-fn</a>)
  (<a id='4021' tid='4022' class='u'>cond</a> ((<a id='4023' tid='4024' class='u'>paredit-in-comment-p</a> <a id='4025' tid='4026' class='u'>parse-state</a>) <a id='4027' tid='4028' class='u'>&#39;</a><a id='4029' tid='4030' class='u'>comment</a>)
        ((<a id='4031' tid='4032' class='u'>paredit-in-string-p</a>  <a id='4033' tid='4034' class='u'>parse-state</a>) <a id='4035' tid='4036' class='u'>&#39;</a><a id='4037' tid='4038' class='u'>string</a>)
        ((<a id='4039' tid='4040' class='u'>memq</a> (<a id='4041' tid='4042' class='u'>char-syntax</a> (<a id='4043' tid='4044' class='u'>funcall</a> <a id='4045' tid='4046' class='u'>adjacent-char-fn</a>))
               <a id='4047' tid='4048' class='u'>&#39;</a>(<a id='4049' tid='4050' class='u'>?\(</a> <a id='4051' tid='4052' class='u'>?\)</a> ))
         <a id='4053' tid='4054' class='u'>&#39;</a><a id='4055' tid='4056' class='u'>delimiter</a>)
        (<a id='4057' tid='4058' class='u'>t</a> <a id='4059' tid='4060' class='u'>&#39;</a><a id='4061' tid='4062' class='u'>other</a>)))

<span class='d'>;;; This optionally advances the point past any comment delimiters that
</span><span class='d'>;;; should probably not be touched, based on the last state change and
</span><span class='d'>;;; the characters around the point.  It returns a new parse state,
</span><span class='d'>;;; starting from the PARSE-STATE parameter.
</span>
(<a id='3911' tid='3912' class='u'>defun</a> <a id='3913' tid='3914' class='u'>paredit-kill-word-hack</a> (<a id='3915' tid='3916' class='u'>old-state</a> <a id='3917' tid='3918' class='u'>new-state</a> <a id='3919' tid='3920' class='u'>parse-state</a>)
  (<a id='3921' tid='3922' class='u'>cond</a> ((<a id='3923' tid='3924' class='u'>and</a> (<a id='3925' tid='3926' class='u'>not</a> (<a id='3927' tid='3928' class='u'>eq</a> <a id='3929' tid='3930' class='u'>old-state</a> <a id='3931' tid='3932' class='u'>&#39;</a><a id='3933' tid='3934' class='u'>comment</a>))
              (<a id='3935' tid='3936' class='u'>not</a> (<a id='3937' tid='3938' class='u'>eq</a> <a id='3939' tid='3940' class='u'>new-state</a> <a id='3941' tid='3942' class='u'>&#39;</a><a id='3943' tid='3944' class='u'>comment</a>))
              (<a id='3945' tid='3946' class='u'>not</a> (<a id='3947' tid='3948' class='u'>paredit-in-string-escape-p</a>))
              (<a id='3949' tid='3950' class='u'>eq</a> <a id='3951' tid='3952' class='u'>?\#</a> (<a id='3953' tid='3954' class='u'>char-before</a>))
              (<a id='3955' tid='3956' class='u'>eq</a> <a id='3957' tid='3958' class='u'>?\|</a> (<a id='3959' tid='3960' class='u'>char-after</a>)))
         (<a id='3961' tid='3962' class='u'>forward-char</a> <a id='3963' tid='3964' class='u'>1</a>)
         (<a id='3965' tid='3966' class='u'>paredit-current-parse-state</a>)
<a id='3967' tid='3968' class='u'>;;          (parse-partial-sexp (point) (1+ (point))
</a><a id='3969' tid='3970' class='u'>;;                              nil nil parse-state)
</a>         )
        ((<a id='3971' tid='3972' class='u'>and</a> (<a id='3973' tid='3974' class='u'>not</a> (<a id='3975' tid='3976' class='u'>eq</a> <a id='3977' tid='3978' class='u'>old-state</a> <a id='3979' tid='3980' class='u'>&#39;</a><a id='3981' tid='3982' class='u'>comment</a>))
              (<a id='3983' tid='3984' class='u'>eq</a> <a id='3985' tid='3986' class='u'>new-state</a> <a id='3987' tid='3988' class='u'>&#39;</a><a id='3989' tid='3990' class='u'>comment</a>)
              (<a id='3991' tid='3992' class='u'>eq</a> <a id='3993' tid='3994' class='u'>?\;</a> (<a id='3995' tid='3996' class='u'>char-before</a>)))
         (<a id='3997' tid='3998' class='u'>skip-chars-forward</a> <a id='3999' tid='4000' class='u'>&quot;;&quot;</a>)
         (<a id='4001' tid='4002' class='u'>paredit-current-parse-state</a>)
<a id='4003' tid='4004' class='u'>;;          (parse-partial-sexp (point) (save-excursion
</a><a id='4005' tid='4006' class='u'>;;                                        (skip-chars-forward &quot;;&quot;))
</a><a id='4007' tid='4008' class='u'>;;                              nil nil parse-state)
</a>         )
        (<a id='4009' tid='4010' class='u'>t</a> <a id='4011' tid='4012' class='u'>parse-state</a>)))

<span class='d'>;;;; Cursor and Screen Movement
</span>
(<a id='4787' tid='4788' class='u'>eval-and-compile</a>
  (<a id='4825' tid='4826' class='u'>defmacro</a> <a id='4827' tid='4828' class='u'>defun-saving-mark</a> (<a id='4829' tid='4830' class='u'>name</a> <a id='4831' tid='4832' class='u'>bvl</a> <a id='4833' tid='4834' class='u'>doc</a> <a id='4835' tid='4836' class='u'>&rest</a> <a id='4837' tid='4838' class='u'>body</a>)
    <a id='4839' tid='4840' class='u'>`</a>(<a id='4789' tid='4790' class='u'>defun</a> <a id='4791' tid='4792' class='u'>,</a><a id='4793' tid='4794' class='u'>name</a> <a id='4795' tid='4796' class='u'>,</a><a id='4797' tid='4798' class='u'>bvl</a>
       <a id='4799' tid='4800' class='u'>,</a><a id='4801' tid='4802' class='u'>doc</a>
       <a id='4803' tid='4804' class='u'>,</a>(<a id='4805' tid='4806' class='u'>xcond</a> ((<a id='4807' tid='4808' class='u'>paredit-xemacs-p</a>)
                <a id='4809' tid='4810' class='u'>&#39;</a>(<a id='4811' tid='4812' class='u'>interactive</a> <a id='4813' tid='4814' class='u'>&quot;_&quot;</a>))
               ((<a id='4815' tid='4816' class='u'>paredit-gnu-emacs-p</a>)
                <a id='4817' tid='4818' class='u'>&#39;</a>(<a id='4819' tid='4820' class='u'>interactive</a>)))
       <a id='4821' tid='4822' class='u'>,</a><a id='4823' tid='4824' class='u'>@body</a>)))

(<a id='4841' tid='4842' class='u'>defun-saving-mark</a> <a id='4843' tid='4844' class='u'>paredit-forward</a> ()
  <a id='4845' tid='4846' class='u'>&quot;Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
  delimiter, move past that closing delimiter; otherwise, move forward
  past the S-expression following the point.&quot;</a>
  (<a id='4847' tid='4848' class='u'>paredit-handle-sexp-errors</a>
      (<a id='4849' tid='4850' class='u'>forward-sexp</a>)
    <a id='4851' tid='4852' class='u'>;++ Is it necessary to use UP-LIST and not just FORWARD-CHAR?
</a>    (<a id='4853' tid='4854' class='u'>if</a> (<a id='4855' tid='4856' class='u'>paredit-in-string-p</a>) (<a id='4857' tid='4858' class='u'>forward-char</a>) (<a id='4859' tid='4860' class='u'>up-list</a>))))

(<a id='4861' tid='4862' class='u'>defun-saving-mark</a> <a id='4863' tid='4864' class='u'>paredit-backward</a> ()
  <a id='4865' tid='4866' class='u'>&quot;Move backward an S-expression, or up an S-expression backward.
If there are no more S-expressions in this one before the opening
  delimiter, move past that opening delimiter backward; otherwise, move
  move backward past the S-expression preceding the point.&quot;</a>
  (<a id='4867' tid='4868' class='u'>paredit-handle-sexp-errors</a>
      (<a id='4869' tid='4870' class='u'>backward-sexp</a>)
    (<a id='4871' tid='4872' class='u'>if</a> (<a id='4873' tid='4874' class='u'>paredit-in-string-p</a>) (<a id='4875' tid='4876' class='u'>backward-char</a>) (<a id='4877' tid='4878' class='u'>backward-up-list</a>))))

<a id='4879' tid='4880' class='u'>;;; Why is this not in lisp.el?
</a>
(<a id='1493' tid='1494' class='u'>defun</a> <a id='1495' tid='1496' class='u'>backward-down-list</a> (<a id='1497' tid='1498' class='u'>&optional</a> <a id='1499' tid='1500' class='u'>arg</a>)
  <a id='1501' tid='1502' class='u'>&quot;Move backward and descend into one level of parentheses.
With ARG, do this that many times.
A negative argument means move forward but still descend a level.&quot;</a>
  (<a id='1503' tid='1504' class='u'>interactive</a> <a id='1505' tid='1506' class='u'>&quot;p&quot;</a>)
  (<a id='1507' tid='1508' class='u'>down-list</a> (<a id='1509' tid='1510' class='u'>-</a> (<a id='1511' tid='1512' class='u'>or</a> <a id='1513' tid='1514' class='u'>arg</a> <a id='1515' tid='1516' class='u'>1</a>))))

<a id='4881' tid='4882' class='u'>;;; Thanks to Marco Baringer for suggesting & writing this function.
</a>
(<a id='4263' tid='4264' class='u'>defun</a> <a id='4265' tid='4266' class='u'>paredit-recentre-on-sexp</a> (<a id='4267' tid='4268' class='u'>&optional</a> <a id='4269' tid='4270' class='u'>n</a>)
  <a id='4271' tid='4272' class='u'>&quot;Recentre the screen on the S-expression following the point.
With a prefix argument N, encompass all N S-expressions forward.&quot;</a>
  (<a id='4273' tid='4274' class='u'>interactive</a> <a id='4275' tid='4276' class='u'>&quot;P&quot;</a>)
  (<a id='4277' tid='4278' class='u'>save-excursion</a>
    (<a id='4279' tid='4280' class='u'>forward-sexp</a> <a id='4281' tid='4282' class='u'>n</a>)
    (<a id='4283' tid='4284' class='u'>let</a> ((<a id='4285' tid='4286' class='u'>end-point</a> (<a id='4287' tid='4288' class='u'>point</a>)))
      (<a id='4289' tid='4290' class='u'>backward-sexp</a> <a id='4291' tid='4292' class='u'>n</a>)
      (<a id='4293' tid='4294' class='u'>let*</a> ((<a id='4295' tid='4296' class='u'>start-point</a> (<a id='4297' tid='4298' class='u'>point</a>))
             (<a id='4299' tid='4300' class='u'>start-line</a> (<a id='4301' tid='4302' class='u'>count-lines</a> (<a id='4303' tid='4304' class='u'>point-min</a>) (<a id='4305' tid='4306' class='u'>point</a>)))
             (<a id='4307' tid='4308' class='u'>lines-on-sexps</a> (<a id='4309' tid='4310' class='u'>count-lines</a> <a id='4311' tid='4312' class='u'>start-point</a> <a id='4313' tid='4314' class='u'>end-point</a>)))
        (<a id='4315' tid='4316' class='u'>goto-line</a> (<a id='4317' tid='4318' class='u'>+</a> <a id='4319' tid='4320' class='u'>start-line</a> (<a id='4321' tid='4322' class='u'>/</a> <a id='4323' tid='4324' class='u'>lines-on-sexps</a> <a id='4325' tid='4326' class='u'>2</a>)))
        (<a id='4327' tid='4328' class='u'>recenter</a>)))))

<span class='d'>;;;; Depth-Changing Commands:  Wrapping, Splicing, & Raising
</span>
(<a id='4613' tid='4614' class='u'>defun</a> <a id='4615' tid='4616' class='u'>paredit-wrap-sexp</a> <span class='d'>(&optional n)</span>
  <span class='d'>&quot;Wrap the following S-expression in a list.
If a prefix argument N is given, wrap N S-expressions.
Automatically indent the newly wrapped S-expression.
As a special case, if the point is at the end of a list, simply insert
  a pair of parentheses, rather than insert a lone opening parenthesis
  and then signal an error, in the interest of preserving structure.&quot;</span>
  (<a id='4617' tid='4618' class='u'>interactive</a> <a id='4619' tid='4620' class='u'>&quot;P&quot;</a>)
  <span class='d'>(paredit-handle-sexp-errors
      (paredit-insert-pair (or n
                               (and (not (paredit-region-active-p))
                                    1))
                           ?\( ?\)
                           &#39;goto-char)
    (insert ?\) )
    (backward-char))</span>
  (<a id='4621' tid='4622' class='u'>save-excursion</a> (<a id='4623' tid='4624' class='u'>backward-up-list</a>) (<a id='4625' tid='4626' class='u'>indent-sexp</a>)))

<span class='d'>;;; Thanks to Marco Baringer for the suggestion of a prefix argument
</span><span class='d'>;;; for PAREDIT-SPLICE-SEXP.  (I, Taylor R. Campbell, however, still
</span><span class='d'>;;; implemented it, in case any of you lawyer-folk get confused by the
</span><span class='d'>;;; remark in the top of the file about explicitly noting code written
</span><span class='d'>;;; by other people.)
</span>
(<a id='4493' tid='4494' class='u'>defun</a> <a id='4495' tid='4496' class='u'>paredit-splice-sexp</a> <span class='d'>(&optional arg)</span>
  <span class='d'>&quot;Splice the list that the point is on by removing its delimiters.
With a prefix argument as in `C-u&#39;, kill all S-expressions backward in
  the current list before splicing all S-expressions forward into the
  enclosing list.
With two prefix arguments as in `C-u C-u&#39;, kill all S-expressions
  forward in the current list before splicing all S-expressions
  backward into the enclosing list.
With a numerical prefix argument N, kill N S-expressions backward in
  the current list before splicing the remaining S-expressions into the
  enclosing list.  If N is negative, kill forward.
This always creates a new entry on the kill ring.&quot;</span>
  (<a id='4497' tid='4498' class='u'>interactive</a> <a id='4499' tid='4500' class='u'>&quot;P&quot;</a>)
  <span class='d'>(save-excursion
    (paredit-kill-surrounding-sexps-for-splice arg)
    (backward-up-list)                  ; Go up to the beginning...
    (save-excursion
      (forward-sexp)                    ; Go forward an expression, to
      (backward-delete-char 1))         ;   delete the end delimiter.
    (delete-char 1)                     ; ...to delete the open char.
    (paredit-ignore-sexp-errors
      (backward-up-list)                ; Reindent, now that the
      (indent-sexp)))</span>)                  <span class='d'>;   structure has changed.
</span>
(<a id='3907' tid='3908' class='u'>defun</a> <a id='3909' tid='3910' class='u'>paredit-kill-surrounding-sexps-for-splice</a> <span class='d'>(arg)</span>
  (<span class='d'>cond</span> <span class='d'>((paredit-in-string-p) (error &quot;Splicing illegal in strings.&quot;))</span>
        <span class='d'>((or (not arg) (eq arg 0)) nil)</span>
        <span class='d'>((or (numberp arg) (eq arg &#39;-))
         ;; Kill ARG S-expressions before/after the point by saving
         ;; the point, moving across them, and killing the region.
         (let* ((arg (if (eq arg &#39;-) -1 arg))
                (saved (paredit-point-at-sexp-boundary (- arg))))
           (paredit-ignore-sexp-errors (backward-sexp arg))
           (kill-region-new saved (point))))</span>
        (<span class='d'>(consp arg)</span>
         (<span class='d'>let</span> <span class='d'>((v (car arg)))</span>
           (<a id='1209' tid='1210' class='m'>if</a> (<a id='1211' tid='1212' class='m'>=</a> <a id='1213' tid='1214' class='m'>v</a> <a id='1215' tid='1216' class='m'>4</a>)                  <span class='d'>; one prefix argument
</span>               <a id='1217' tid='1218' class='m'>;; Move backward until we hit the open paren; then
</a>               <a id='1219' tid='1220' class='m'>;; kill that selected region.
</a>               (<span class='d'>let</span> <span class='d'>((end (paredit-point-at-sexp-start)))</span>
                 (<a id='1221' tid='1222' class='m'>paredit-ignore-sexp-errors</a>
                   (<a id='1223' tid='1224' class='m'>while</a> (<a id='1225' tid='1226' class='m'>not</a> (<a id='1227' tid='1228' class='m'>bobp</a>))
                     (<a id='1229' tid='1230' class='m'>backward-sexp</a>)))
                 <span class='d'>(kill-region-new (point) end)</span>)
               <a id='1231' tid='1232' class='m'>;; Move forward until we hit the close paren; then
</a>               <a id='1233' tid='1234' class='m'>;; kill that selected region.
</a>               (<span class='d'>let</span> <span class='d'>((beginning (paredit-point-at-sexp-end)))</span>
                 (<a id='1235' tid='1236' class='m'>paredit-ignore-sexp-errors</a>
                   (<a id='1237' tid='1238' class='m'>while</a> (<a id='1239' tid='1240' class='m'>not</a> (<a id='1241' tid='1242' class='m'>eobp</a>))
                     (<a id='1243' tid='1244' class='m'>forward-sexp</a>)))
                 <span class='d'>(kill-region-new beginning (point))</span>))))
        <span class='d'>(t (error &quot;Bizarre prefix argument: %s&quot; arg))</span>))

(<a id='4501' tid='4502' class='u'>defun</a> <a id='4503' tid='4504' class='u'>paredit-splice-sexp-killing-backward</a> (<a id='4505' tid='4506' class='u'>&optional</a> <a id='4507' tid='4508' class='u'>n</a>)
  <a id='4509' tid='4510' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions before the point in the current list.
With a prefix argument N, kill only the preceding N S-expressions.&quot;</a>
  (<a id='4511' tid='4512' class='u'>interactive</a> <a id='4513' tid='4514' class='u'>&quot;P&quot;</a>)
  (<a id='4515' tid='4516' class='u'>paredit-splice-sexp</a> (<a id='4517' tid='4518' class='u'>if</a> <a id='4519' tid='4520' class='u'>n</a>
                           (<a id='4521' tid='4522' class='u'>prefix-numeric-value</a> <a id='4523' tid='4524' class='u'>n</a>)
                           <a id='4525' tid='4526' class='u'>&#39;</a>(<a id='4527' tid='4528' class='u'>4</a>))))

(<a id='4529' tid='4530' class='u'>defun</a> <a id='4531' tid='4532' class='u'>paredit-splice-sexp-killing-forward</a> (<a id='4533' tid='4534' class='u'>&optional</a> <a id='4535' tid='4536' class='u'>n</a>)
  <a id='4537' tid='4538' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions after the point in the current list.
With a prefix argument N, kill only the following N S-expressions.&quot;</a>
  (<a id='4539' tid='4540' class='u'>interactive</a> <a id='4541' tid='4542' class='u'>&quot;P&quot;</a>)
  (<a id='4543' tid='4544' class='u'>paredit-splice-sexp</a> (<a id='4545' tid='4546' class='u'>if</a> <a id='4547' tid='4548' class='u'>n</a>
                           (<a id='4549' tid='4550' class='u'>-</a> (<a id='4551' tid='4552' class='u'>prefix-numeric-value</a> <a id='4553' tid='4554' class='u'>n</a>))
                           <a id='4555' tid='4556' class='u'>&#39;</a>(<a id='4557' tid='4558' class='u'>16</a>))))

(<a id='4259' tid='4260' class='u'>defun</a> <a id='4261' tid='4262' class='u'>paredit-raise-sexp</a> <span class='d'>(&optional n)</span>
  <span class='d'>&quot;Raise the following S-expression in a tree, deleting its siblings.
With a prefix argument N, raise the following N S-expressions.  If N
  is negative, raise the preceding N S-expressions.&quot;</span>
  <span class='d'>(interactive &quot;p&quot;)</span>
  <span class='d'>;; Select the S-expressions we want to raise in a buffer substring.
</span>  <span class='d'>(let* ((bound (save-excursion (forward-sexp n) (point)))
         (sexps (save-excursion         ;++ Is this necessary?
                  (if (and n (&lt; n 0))
                      (buffer-substring bound
                                        (paredit-point-at-sexp-end))
                      (buffer-substring (paredit-point-at-sexp-start)
                                        bound)))))
    ;; Move up to the list we&#39;re raising those S-expressions out of and
    ;; delete it.
    (backward-up-list)
    (delete-region (point) (save-excursion (forward-sexp) (point)))
    (save-excursion (insert sexps))     ; Insert & reindent the sexps.
    (save-excursion (let ((n (abs (or n 1))))
                      (while (&gt; n 0)
                        (paredit-forward-and-indent)
                        (setq n (1- n))))))</span>)

<a id='4883' tid='4884' class='u'>;;;; Slurpage & Barfage
</a>
(<a id='3097' tid='3098' class='u'>defun</a> <a id='3099' tid='3100' class='u'>paredit-forward-slurp-sexp</a> ()
  <a id='3101' tid='3102' class='u'>&quot;Add the S-expression following the current list into that list
  by moving the closing delimiter.
Automatically reindent the newly slurped S-expression with respect to
  its new enclosing form.
If in a string, move the opening double-quote forward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='3103' tid='3104' class='u'>interactive</a>)
  <span class='d'>(save-excursion
    (cond ((or (paredit-in-comment-p)
               (paredit-in-char-p))
           (error &quot;Invalid context for slurpage&quot;))
          ((paredit-in-string-p)
           (paredit-forward-slurp-into-string))
          (t
           (paredit-forward-slurp-into-list))))</span>)

(<a id='3047' tid='3048' class='u'>defun</a> <a id='3049' tid='3050' class='u'>paredit-forward-slurp-into-list</a> ()
  (<a id='3051' tid='3052' class='u'>up-list</a>)                             <a id='3053' tid='3054' class='u'>; Up to the end of the list to
</a>  (<a id='1245' tid='1246' class='m'>let</a> ((<a id='1247' tid='1248' class='m'>close</a> (<a id='1249' tid='1250' class='m'>char-before</a>)))          <a id='1251' tid='1252' class='m'>;   save and delete the closing
</a>    (<a id='1253' tid='1254' class='m'>backward-delete-char</a> <a id='1255' tid='1256' class='m'>1</a>)            <a id='1257' tid='1258' class='m'>;   delimiter.
</a>    (<a id='1259' tid='1260' class='m'>catch</a> <a id='1261' tid='1262' class='m'>&#39;</a><a id='1263' tid='1264' class='m'>return</a>                      <a id='1265' tid='1266' class='m'>; Go to the end of the desired
</a>      (<a id='1267' tid='1268' class='m'>while</a> <a id='1269' tid='1270' class='m'>t</a>                          <a id='1271' tid='1272' class='m'>;   S-expression, going up a
</a>        (<span class='d'>paredit-handle-sexp-errors</span>     <span class='d'>;   list if it&#39;s not in this,
</span>            (<a id='1273' tid='1274' class='m'>progn</a> (<a id='1275' tid='1276' class='m'>paredit-forward-and-indent</a>)
                   (<a id='1277' tid='1278' class='m'>throw</a> <a id='1279' tid='1280' class='m'>&#39;</a><a id='1281' tid='1282' class='m'>return</a> <a id='1283' tid='1284' class='m'>nil</a>))
          <span class='d'>(up-list)</span>)))
    (<a id='1285' tid='1286' class='m'>insert</a> <a id='1287' tid='1288' class='m'>close</a>)))                    <a id='4885' tid='4886' class='u'>; to insert that delimiter.
</a>
(<a id='3055' tid='3056' class='u'>defun</a> <a id='3057' tid='3058' class='u'>paredit-forward-slurp-into-string</a> ()
  (<a id='3059' tid='3060' class='u'>goto-char</a> (<a id='3061' tid='3062' class='u'>1+</a> (<a id='3063' tid='3064' class='u'>cdr</a> (<a id='3065' tid='3066' class='u'>paredit-string-start+end-points</a>))))
  <a id='3067' tid='3068' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='3069' tid='3070' class='u'>;; buffer&#39;s contents.
</a>  (<a id='3071' tid='3072' class='u'>save-excursion</a> (<a id='3073' tid='3074' class='u'>forward-sexp</a>))
  (<a id='3075' tid='3076' class='u'>let</a> ((<a id='3077' tid='3078' class='u'>close</a> (<a id='3079' tid='3080' class='u'>char-before</a>)))
    (<a id='3081' tid='3082' class='u'>backward-delete-char</a> <a id='3083' tid='3084' class='u'>1</a>)
    (<a id='3085' tid='3086' class='u'>paredit-forward-for-quote</a> (<a id='3087' tid='3088' class='u'>save-excursion</a> (<a id='3089' tid='3090' class='u'>forward-sexp</a>) (<a id='3091' tid='3092' class='u'>point</a>)))
    (<a id='3093' tid='3094' class='u'>insert</a> <a id='3095' tid='3096' class='u'>close</a>)))

(<a id='2437' tid='2438' class='u'>defun</a> <a id='2439' tid='2440' class='u'>paredit-forward-barf-sexp</a> ()
  <a id='2441' tid='2442' class='u'>&quot;Remove the last S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the newly barfed S-expression with respect to
  its new enclosing form.&quot;</a>
  (<a id='2443' tid='2444' class='u'>interactive</a>)
  (<a id='2445' tid='2446' class='u'>save-excursion</a>
    (<a id='2447' tid='2448' class='u'>up-list</a>)                           <a id='2449' tid='2450' class='u'>; Up to the end of the list to
</a>    (<a id='2451' tid='2452' class='u'>let</a> ((<a id='2453' tid='2454' class='u'>close</a> (<a id='2455' tid='2456' class='u'>char-before</a>)))        <a id='2457' tid='2458' class='u'>;   save and delete the closing
</a>      (<a id='2459' tid='2460' class='u'>backward-delete-char</a> <a id='2461' tid='2462' class='u'>1</a>)          <a id='2463' tid='2464' class='u'>;   delimiter.
</a>      (<a id='2465' tid='2466' class='u'>paredit-ignore-sexp-errors</a>       <a id='2467' tid='2468' class='u'>; Go back to where we want to
</a>        (<a id='2469' tid='2470' class='u'>backward-sexp</a>))                <a id='2471' tid='2472' class='u'>;   insert the delimiter.
</a>      (<a id='2473' tid='2474' class='u'>paredit-skip-whitespace</a> <a id='2475' tid='2476' class='u'>nil</a>)     <a id='2477' tid='2478' class='u'>; Skip leading whitespace.
</a>      (<a id='2479' tid='2480' class='u'>cond</a> ((<a id='2481' tid='2482' class='u'>bobp</a>)
             (<a id='2483' tid='2484' class='u'>error</a> <a id='2485' tid='2486' class='u'>&quot;Barfing all subexpressions with no open-paren?&quot;</a>))
            ((<a id='2487' tid='2488' class='u'>paredit-in-comment-p</a>)     <a id='2489' tid='2490' class='u'>; Don&#39;t put the close-paren in
</a>             (<a id='2491' tid='2492' class='u'>newline-and-indent</a>)))     <a id='2493' tid='2494' class='u'>;   a comment.
</a>      (<a id='2495' tid='2496' class='u'>insert</a> <a id='2497' tid='2498' class='u'>close</a>))
    <a id='2499' tid='2500' class='u'>;; Reindent all of the newly barfed S-expressions.
</a>    (<a id='2501' tid='2502' class='u'>paredit-forward-and-indent</a>)))

(<a id='2151' tid='2152' class='u'>defun</a> <a id='2153' tid='2154' class='u'>paredit-backward-slurp-sexp</a> ()
  <a id='2155' tid='2156' class='u'>&quot;Add the S-expression preceding the current list into that list
  by moving the closing delimiter.
Automatically reindent the whole form into which new S-expression was
  slurped.
If in a string, move the opening double-quote backward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='2157' tid='2158' class='u'>interactive</a>)
  <span class='d'>(save-excursion
    (cond ((or (paredit-in-comment-p)
               (paredit-in-char-p))
           (error &quot;Invalid context for slurpage&quot;))
          ((paredit-in-string-p)
           (paredit-backward-slurp-into-string))
          (t
           (paredit-backward-slurp-into-list))))</span>)

(<a id='2121' tid='2122' class='u'>defun</a> <a id='2123' tid='2124' class='u'>paredit-backward-slurp-into-list</a> ()
  (<a id='2125' tid='2126' class='u'>backward-up-list</a>)
  (<a id='1289' tid='1290' class='m'>let</a> ((<a id='1291' tid='1292' class='m'>open</a> (<a id='1293' tid='1294' class='m'>char-after</a>)))
    (<a id='1295' tid='1296' class='m'>delete-char</a> <a id='1297' tid='1298' class='m'>1</a>)
    (<a id='1299' tid='1300' class='m'>catch</a> <a id='1301' tid='1302' class='m'>&#39;</a><a id='1303' tid='1304' class='m'>return</a>
      (<a id='1305' tid='1306' class='m'>while</a> <a id='1307' tid='1308' class='m'>t</a>
        (<span class='d'>paredit-handle-sexp-errors</span>
            (<a id='1309' tid='1310' class='m'>progn</a> (<a id='1311' tid='1312' class='m'>backward-sexp</a>)
                   (<a id='1313' tid='1314' class='m'>throw</a> <a id='1315' tid='1316' class='m'>&#39;</a><a id='1317' tid='1318' class='m'>return</a> <a id='1319' tid='1320' class='m'>nil</a>))
          <span class='d'>(backward-up-list)</span>)))
    (<a id='1321' tid='1322' class='m'>insert</a> <a id='1323' tid='1324' class='m'>open</a>))
  <span class='d'>;; Reindent the line at the beginning of wherever we inserted the
</span>  <span class='d'>;; opening parenthesis, and then indent the whole S-expression.
</span>  (<a id='2127' tid='2128' class='u'>backward-up-list</a>)
  (<a id='2129' tid='2130' class='u'>lisp-indent-line</a>)
  (<a id='2131' tid='2132' class='u'>indent-sexp</a>))

(<a id='2133' tid='2134' class='u'>defun</a> <a id='2135' tid='2136' class='u'>paredit-backward-slurp-into-string</a> ()
  (<a id='2137' tid='2138' class='u'>goto-char</a> (<a id='2139' tid='2140' class='u'>car</a> (<a id='2141' tid='2142' class='u'>paredit-string-start+end-points</a>)))
  <a id='2143' tid='2144' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='2145' tid='2146' class='u'>;; buffer&#39;s contents.
</a>  (<a id='2147' tid='2148' class='u'>save-excursion</a> (<a id='2149' tid='2150' class='u'>backward-sexp</a>))
  <span class='d'>(let ((open (char-after))
        (target (point)))
    (message &quot;open = %S&quot; open)
    (delete-char 1)
    (backward-sexp)
    (insert open)
    (paredit-forward-for-quote target))</span>)

(<a id='1799' tid='1800' class='u'>defun</a> <a id='1801' tid='1802' class='u'>paredit-backward-barf-sexp</a> ()
  <a id='1803' tid='1804' class='u'>&quot;Remove the first S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the barfed S-expression and the form from which
  it was barfed.&quot;</a>
  (<a id='1805' tid='1806' class='u'>interactive</a>)
  (<a id='1807' tid='1808' class='u'>save-excursion</a>
    (<a id='1809' tid='1810' class='u'>backward-up-list</a>)
    (<a id='1811' tid='1812' class='u'>let</a> ((<a id='1813' tid='1814' class='u'>open</a> (<a id='1815' tid='1816' class='u'>char-after</a>)))
      (<a id='1817' tid='1818' class='u'>delete-char</a> <a id='1819' tid='1820' class='u'>1</a>)
      (<a id='1821' tid='1822' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='1823' tid='1824' class='u'>paredit-forward-and-indent</a>))
      (<a id='1825' tid='1826' class='u'>while</a> (<a id='1827' tid='1828' class='u'>progn</a> (<a id='1829' tid='1830' class='u'>paredit-skip-whitespace</a> <a id='1831' tid='1832' class='u'>t</a>)
                    (<a id='1833' tid='1834' class='u'>eq</a> (<a id='1835' tid='1836' class='u'>char-after</a>) <a id='1837' tid='1838' class='u'>?\;</a> ))
        (<a id='1839' tid='1840' class='u'>forward-line</a> <a id='1841' tid='1842' class='u'>1</a>))
      (<a id='1843' tid='1844' class='u'>if</a> (<a id='1845' tid='1846' class='u'>eobp</a>)
          (<a id='1847' tid='1848' class='u'>error</a>
           <a id='1849' tid='1850' class='u'>&quot;Barfing all subexpressions with no close-paren?&quot;</a>))
      <a id='1851' tid='1852' class='u'>;** Don&#39;t use `insert&#39; here.  Consider, e.g., barfing from
</a>      <a id='1853' tid='1854' class='u'>;**   (foo|)
</a>      <a id='1855' tid='1856' class='u'>;** and how `save-excursion&#39; works.
</a>      (<a id='1857' tid='1858' class='u'>insert-before-markers</a> <a id='1859' tid='1860' class='u'>open</a>))
    (<a id='1861' tid='1862' class='u'>backward-up-list</a>)
    (<a id='1863' tid='1864' class='u'>lisp-indent-line</a>)
    (<a id='1865' tid='1866' class='u'>indent-sexp</a>)))

<a id='4887' tid='4888' class='u'>;;;; Splitting & Joining
</a>
(<a id='4559' tid='4560' class='u'>defun</a> <a id='4561' tid='4562' class='u'>paredit-split-sexp</a> ()
  <a id='4563' tid='4564' class='u'>&quot;Split the list or string the point is on into two.&quot;</a>
  (<a id='4565' tid='4566' class='u'>interactive</a>)
  (<span class='d'>cond</span> ((<a id='1325' tid='1326' class='m'>paredit-in-string-p</a>)
         (<a id='1327' tid='1328' class='m'>insert</a> <a id='1329' tid='1330' class='m'>&quot;\&quot;&quot;</a>)
         (<a id='1331' tid='1332' class='m'>save-excursion</a> (<a id='1333' tid='1334' class='m'>insert</a> <a id='1335' tid='1336' class='m'>&quot; \&quot;&quot;</a>)))
        <span class='d'>((or (paredit-in-comment-p)
             (paredit-in-char-p))
         (error &quot;Invalid context for `paredit-split-sexp&#39;&quot;))</span>
        (<a id='573' tid='574' class='m'>t</a> (<a id='575' tid='576' class='m'>let</a> ((<a id='577' tid='578' class='m'>open</a>  (<a id='579' tid='580' class='m'>save-excursion</a> (<a id='581' tid='582' class='m'>backward-up-list</a>)
                                        (<a id='583' tid='584' class='m'>char-after</a>)))
                 (<a id='585' tid='586' class='m'>close</a> (<a id='587' tid='588' class='m'>save-excursion</a> (<a id='589' tid='590' class='m'>up-list</a>)
                                        (<a id='591' tid='592' class='m'>char-before</a>))))
             (<a id='593' tid='594' class='m'>delete-horizontal-space</a>)
             (<a id='595' tid='596' class='m'>insert</a> <a id='597' tid='598' class='m'>close</a>)
             (<a id='599' tid='600' class='m'>save-excursion</a> (<a id='601' tid='602' class='m'>insert</a> <a id='603' tid='604' class='m'>?\ </a>)
                             (<a id='605' tid='606' class='m'>insert</a> <a id='607' tid='608' class='m'>open</a>)
                             (<a id='609' tid='610' class='m'>backward-char</a>)
                             (<a id='611' tid='612' class='m'>indent-sexp</a>))))))

(<a id='3647' tid='3648' class='u'>defun</a> <a id='3649' tid='3650' class='u'>paredit-join-sexps</a> ()
  <a id='3651' tid='3652' class='u'>&quot;Join the S-expressions adjacent on either side of the point.
Both must be lists, strings, or atoms; error if there is a mismatch.&quot;</a>
  (<a id='3653' tid='3654' class='u'>interactive</a>)
  <a id='3655' tid='3656' class='u'>;++ How ought this to handle comments intervening symbols or strings?
</a>  (<a id='1337' tid='1338' class='m'>save-excursion</a>
    (<span class='d'>if</span> <span class='d'>(or (paredit-in-comment-p)
            (paredit-in-string-p)
            (paredit-in-char-p))</span>
        <span class='d'>(error &quot;Invalid context in which to join S-expressions.&quot;)</span>
      (<span class='d'>let</span> <span class='d'>((left-point  (save-excursion (paredit-point-at-sexp-end)))
            (right-point (save-excursion
                           (paredit-point-at-sexp-start))))</span>
        (<a id='1339' tid='1340' class='m'>let</a> ((<a id='1341' tid='1342' class='m'>left-char</a> (<a id='1343' tid='1344' class='m'>char-before</a> <a id='1345' tid='1346' class='m'>left-point</a>))
              (<a id='1347' tid='1348' class='m'>right-char</a> (<a id='1349' tid='1350' class='m'>char-after</a> <a id='1351' tid='1352' class='m'>right-point</a>)))
          (<a id='1353' tid='1354' class='m'>let</a> ((<a id='1355' tid='1356' class='m'>left-syntax</a> (<a id='1357' tid='1358' class='m'>char-syntax</a> <a id='1359' tid='1360' class='m'>left-char</a>))
                (<a id='1361' tid='1362' class='m'>right-syntax</a> (<a id='1363' tid='1364' class='m'>char-syntax</a> <a id='1365' tid='1366' class='m'>right-char</a>)))
            (<a id='1367' tid='1368' class='m'>cond</a> ((<a id='1369' tid='1370' class='m'>&gt;=</a> <a id='1371' tid='1372' class='m'>left-point</a> <a id='1373' tid='1374' class='m'>right-point</a>)
                   (<a id='1375' tid='1376' class='m'>error</a> <a id='1377' tid='1378' class='m'>&quot;Can&#39;t join a datum with itself.&quot;</a>))
                  ((<a id='1379' tid='1380' class='m'>and</a> (<a id='1381' tid='1382' class='m'>eq</a> <a id='1383' tid='1384' class='m'>left-syntax</a>  <a id='1385' tid='1386' class='m'>?\)</a> )
                        (<a id='1387' tid='1388' class='m'>eq</a> <a id='1389' tid='1390' class='m'>right-syntax</a> <a id='1391' tid='1392' class='m'>?\(</a> )
                        (<a id='1393' tid='1394' class='m'>eq</a> <a id='1395' tid='1396' class='m'>left-char</a> (<a id='1397' tid='1398' class='m'>matching-paren</a> <a id='1399' tid='1400' class='m'>right-char</a>))
                        (<a id='1401' tid='1402' class='m'>eq</a> <a id='1403' tid='1404' class='m'>right-char</a> (<a id='1405' tid='1406' class='m'>matching-paren</a> <a id='1407' tid='1408' class='m'>left-char</a>)))
                   <a id='1409' tid='1410' class='m'>;; Leave intermediate formatting alone.
</a>                   (<a id='1411' tid='1412' class='m'>goto-char</a> <a id='1413' tid='1414' class='m'>right-point</a>)
                   (<a id='1415' tid='1416' class='m'>delete-char</a> <a id='1417' tid='1418' class='m'>1</a>)
                   (<a id='1419' tid='1420' class='m'>goto-char</a> <a id='1421' tid='1422' class='m'>left-point</a>)
                   (<a id='1423' tid='1424' class='m'>backward-delete-char</a> <a id='1425' tid='1426' class='m'>1</a>)
                   (<a id='1427' tid='1428' class='m'>backward-up-list</a>)
                   (<a id='1429' tid='1430' class='m'>indent-sexp</a>))
                  ((<a id='1431' tid='1432' class='m'>and</a> (<a id='1433' tid='1434' class='m'>eq</a> <a id='1435' tid='1436' class='m'>left-syntax</a>  <a id='1437' tid='1438' class='m'>?\&quot;</a> )
                        (<a id='1439' tid='1440' class='m'>eq</a> <a id='1441' tid='1442' class='m'>right-syntax</a> <a id='1443' tid='1444' class='m'>?\&quot;</a> ))
                   <a id='1445' tid='1446' class='m'>;; Delete any intermediate formatting.
</a>                   (<a id='1447' tid='1448' class='m'>delete-region</a> (<a id='1449' tid='1450' class='m'>1-</a> <a id='1451' tid='1452' class='m'>left-point</a>)
                                  (<a id='1453' tid='1454' class='m'>1+</a> <a id='1455' tid='1456' class='m'>right-point</a>)))
                  ((<a id='1457' tid='1458' class='m'>and</a> (<a id='1459' tid='1460' class='m'>memq</a> <a id='1461' tid='1462' class='m'>left-syntax</a>  <a id='1463' tid='1464' class='m'>&#39;</a>(<a id='1465' tid='1466' class='m'>?w</a> <a id='1467' tid='1468' class='m'>?_</a>)) <a id='1469' tid='1470' class='m'>; Word or symbol
</a>                        (<a id='1471' tid='1472' class='m'>memq</a> <a id='1473' tid='1474' class='m'>right-syntax</a> <a id='1475' tid='1476' class='m'>&#39;</a>(<a id='1477' tid='1478' class='m'>?w</a> <a id='1479' tid='1480' class='m'>?_</a>)))
                   (<a id='1481' tid='1482' class='m'>delete-region</a> <a id='1483' tid='1484' class='m'>left-point</a> <a id='1485' tid='1486' class='m'>right-point</a>))
                  (<a id='1487' tid='1488' class='m'>t</a>
                   (<a id='1489' tid='1490' class='m'>error</a> <a id='1491' tid='1492' class='m'>&quot;Mismatched S-expressions to join.&quot;</a>)))))))))

<span class='d'>;;;; Utilities
</span>
(<a id='3261' tid='3262' class='u'>defun</a> <a id='3263' tid='3264' class='u'>paredit-in-string-escape-p</a> ()
  <a id='3265' tid='3266' class='u'>&quot;True if the point is on a character escape of a string.
This is true only if the character is preceded by an odd number of
  backslashes.
This assumes that `paredit-in-string-p&#39; has already returned true.&quot;</a>
  (<a id='3267' tid='3268' class='u'>let</a> ((<a id='3269' tid='3270' class='u'>oddp</a> <a id='3271' tid='3272' class='u'>nil</a>))
    (<a id='3273' tid='3274' class='u'>save-excursion</a>
      (<a id='3275' tid='3276' class='u'>while</a> (<a id='3277' tid='3278' class='u'>eq</a> (<a id='3279' tid='3280' class='u'>char-before</a>) <a id='3281' tid='3282' class='u'>?\\</a> )
        (<a id='3283' tid='3284' class='u'>setq</a> <a id='3285' tid='3286' class='u'>oddp</a> (<a id='3287' tid='3288' class='u'>not</a> <a id='3289' tid='3290' class='u'>oddp</a>))
        (<a id='3291' tid='3292' class='u'>backward-char</a>)))
    <a id='3293' tid='3294' class='u'>oddp</a>))

(<a id='3227' tid='3228' class='u'>defun</a> <a id='3229' tid='3230' class='u'>paredit-in-char-p</a> <span class='d'>(&optional arg)</span>
  <a id='3231' tid='3232' class='u'>&quot;True if the point is immediately after a character literal.
A preceding escape character, not preceded by another escape character,
  is considered a character literal prefix.  (This works for elisp,
  Common Lisp, and Scheme.)
Assumes that `paredit-in-string-p&#39; is false, so that it need not handle
  long sequences of preceding backslashes in string escapes.  (This
  assumes some other leading character token -- ? in elisp, # in Scheme
  and Common Lisp.)&quot;</a>
  <span class='d'>(let ((arg (or arg (point))))
    (and (eq (char-before arg) ?\\ )
         (not (eq (char-before (1- arg)) ?\\ ))))</span>)

(<a id='2433' tid='2434' class='u'>defun</a> <a id='2435' tid='2436' class='u'>paredit-forward-and-indent</a> ()
  <span class='d'>&quot;Move forward an S-expression, indenting it fully.
Indent with `lisp-indent-line&#39; and then `indent-sexp&#39;.&quot;</span>
  <span class='d'>(forward-sexp)</span>                        <span class='d'>; Go forward, and then find the
</span>  <span class='d'>(save-excursion                       ;   beginning of this next
    (backward-sexp)                     ;   S-expression.
    (lisp-indent-line)                  ; Indent its opening line, and
    (indent-sexp))</span>)                     <span class='d'>;   the rest of it.
</span>
(<a id='4445' tid='4446' class='u'>defun</a> <a id='4447' tid='4448' class='u'>paredit-skip-whitespace</a> (<a id='4449' tid='4450' class='u'>trailing-p</a> <a id='4451' tid='4452' class='u'>&optional</a> <a id='4453' tid='4454' class='u'>limit</a>)
  <a id='4455' tid='4456' class='u'>&quot;Skip past any whitespace, or until the point LIMIT is reached.
If TRAILING-P is nil, skip leading whitespace; otherwise, skip trailing
  whitespace.&quot;</a>
  (<a id='4457' tid='4458' class='u'>funcall</a> (<a id='4459' tid='4460' class='u'>if</a> <a id='4461' tid='4462' class='u'>trailing-p</a> <a id='4463' tid='4464' class='u'>&#39;</a><a id='4465' tid='4466' class='u'>skip-chars-forward</a> <a id='4467' tid='4468' class='u'>&#39;</a><a id='4469' tid='4470' class='u'>skip-chars-backward</a>)
           <a id='4471' tid='4472' class='u'>&quot; \t\n&quot;</a>  <a id='4473' tid='4474' class='u'>; This should skip using the syntax table, but LF
</a>           <a id='4475' tid='4476' class='u'>limit</a>))    <span class='d'>; is a comment end, not newline, in Lisp mode.
</span>
(<a id='4889' tid='4890' class='u'>defalias</a> <a id='4891' tid='4892' class='u'>&#39;</a><a id='4893' tid='4894' class='u'>paredit-region-active-p</a>
  (<a id='4895' tid='4896' class='u'>xcond</a> ((<a id='4897' tid='4898' class='u'>paredit-xemacs-p</a>) <a id='4899' tid='4900' class='u'>&#39;</a><a id='4901' tid='4902' class='u'>region-active-p</a>)
         ((<a id='4903' tid='4904' class='u'>paredit-gnu-emacs-p</a>)
          (<a id='4905' tid='4906' class='u'>lambda</a> ()
            (<a id='4907' tid='4908' class='u'>and</a> <a id='4909' tid='4910' class='u'>mark-active</a> <a id='4911' tid='4912' class='u'>transient-mark-mode</a>)))))

<span class='d'>(defun kill-region-new (start end)
  &quot;Kill the region between START and END.
Do not append to any current kill, and
 do not let the next kill append to this one.&quot;
  (interactive &quot;r&quot;)                     ;Eh, why not?
  ;; KILL-REGION sets THIS-COMMAND to tell the next kill that the last
  ;; command was a kill.  It also checks LAST-COMMAND to see whether it
  ;; should append.  If we bind these locally, any modifications to
  ;; THIS-COMMAND will be masked, and it will not see LAST-COMMAND to
  ;; indicate that it should append.
  (let ((this-command nil)
        (last-command nil))
    (kill-region start end)))</span>

<a id='4913' tid='4914' class='u'>;;;;; S-expression Parsing Utilities
</a>
<a id='4915' tid='4916' class='u'>;++ These routines redundantly traverse S-expressions a great deal.
</a><a id='4917' tid='4918' class='u'>;++ If performance issues arise, this whole section will probably have
</a><a id='4919' tid='4920' class='u'>;++ to be refactored to preserve the state longer, like paredit.scm
</a><a id='4921' tid='4922' class='u'>;++ does, rather than to traverse the definition N times for every key
</a><a id='4923' tid='4924' class='u'>;++ stroke as it presently does.
</a>
(<a id='2221' tid='2222' class='u'>defun</a> <a id='2223' tid='2224' class='u'>paredit-current-parse-state</a> ()
  <a id='2225' tid='2226' class='u'>&quot;Return parse state of point from beginning of defun.&quot;</a>
  (<a id='2227' tid='2228' class='u'>let</a> ((<a id='2229' tid='2230' class='u'>point</a> (<a id='2231' tid='2232' class='u'>point</a>)))
    (<a id='2233' tid='2234' class='u'>beginning-of-defun</a>)
    <a id='2235' tid='2236' class='u'>;; Calling PARSE-PARTIAL-SEXP will advance the point to its second
</a>    <a id='2237' tid='2238' class='u'>;; argument (unless parsing stops due to an error, but we assume it
</a>    <a id='2239' tid='2240' class='u'>;; won&#39;t in paredit-mode).
</a>    (<a id='2241' tid='2242' class='u'>parse-partial-sexp</a> (<a id='2243' tid='2244' class='u'>point</a>) <a id='2245' tid='2246' class='u'>point</a>)))

(<a id='3295' tid='3296' class='u'>defun</a> <a id='3297' tid='3298' class='u'>paredit-in-string-p</a> (<a id='3299' tid='3300' class='u'>&optional</a> <a id='3301' tid='3302' class='u'>state</a>)
  <a id='3303' tid='3304' class='u'>&quot;True if the parse state is within a double-quote-delimited string.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='3305' tid='3306' class='u'>;; 3. non-nil if inside a string (the terminator character, really)
</a>  (<a id='3307' tid='3308' class='u'>and</a> (<a id='3309' tid='3310' class='u'>nth</a> <a id='3311' tid='3312' class='u'>3</a> (<a id='3313' tid='3314' class='u'>or</a> <a id='3315' tid='3316' class='u'>state</a> (<a id='3317' tid='3318' class='u'>paredit-current-parse-state</a>)))
       <a id='3319' tid='3320' class='u'>t</a>))

(<a id='4567' tid='4568' class='u'>defun</a> <a id='4569' tid='4570' class='u'>paredit-string-start+end-points</a> (<a id='4571' tid='4572' class='u'>&optional</a> <a id='4573' tid='4574' class='u'>state</a>)
  <a id='4575' tid='4576' class='u'>&quot;Return a cons of the points of open and close quotes of the string.
The string is determined from the parse state STATE, or the parse state
  from the beginning of the defun to the point.
This assumes that `paredit-in-string-p&#39; has already returned true, i.e.
  that the point is already within a string.&quot;</a>
  (<a id='4577' tid='4578' class='u'>save-excursion</a>
    <a id='4579' tid='4580' class='u'>;; 8. character address of start of comment or string; nil if not
</a>    <a id='4581' tid='4582' class='u'>;;    in one
</a>    (<a id='4583' tid='4584' class='u'>let</a> ((<a id='4585' tid='4586' class='u'>start</a> (<a id='4587' tid='4588' class='u'>nth</a> <a id='4589' tid='4590' class='u'>8</a> (<a id='4591' tid='4592' class='u'>or</a> <a id='4593' tid='4594' class='u'>state</a> (<a id='4595' tid='4596' class='u'>paredit-current-parse-state</a>)))))
      (<a id='4597' tid='4598' class='u'>goto-char</a> <a id='4599' tid='4600' class='u'>start</a>)
      (<a id='4601' tid='4602' class='u'>forward-sexp</a> <a id='4603' tid='4604' class='u'>1</a>)
      (<a id='4605' tid='4606' class='u'>cons</a> <a id='4607' tid='4608' class='u'>start</a> (<a id='4609' tid='4610' class='u'>1-</a> (<a id='4611' tid='4612' class='u'>point</a>))))))

(<a id='3233' tid='3234' class='u'>defun</a> <a id='3235' tid='3236' class='u'>paredit-in-comment-p</a> (<a id='3237' tid='3238' class='u'>&optional</a> <a id='3239' tid='3240' class='u'>state</a>)
  <a id='3241' tid='3242' class='u'>&quot;True if parse state STATE is within a comment.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='3243' tid='3244' class='u'>;; 4. nil if outside a comment, t if inside a non-nestable comment,
</a>  <a id='3245' tid='3246' class='u'>;;    else an integer (the current comment nesting)
</a>  (<a id='3247' tid='3248' class='u'>and</a> (<a id='3249' tid='3250' class='u'>nth</a> <a id='3251' tid='3252' class='u'>4</a> (<a id='3253' tid='3254' class='u'>or</a> <a id='3255' tid='3256' class='u'>state</a> (<a id='3257' tid='3258' class='u'>paredit-current-parse-state</a>)))
       <a id='3259' tid='3260' class='u'>t</a>))

(<a id='4219' tid='4220' class='u'>defun</a> <a id='4221' tid='4222' class='u'>paredit-point-at-sexp-boundary</a> (<a id='4223' tid='4224' class='u'>n</a>)
  (<a id='4225' tid='4226' class='u'>cond</a> ((<a id='4227' tid='4228' class='u'>&lt;</a> <a id='4229' tid='4230' class='u'>n</a> <a id='4231' tid='4232' class='u'>0</a>) (<a id='4233' tid='4234' class='u'>paredit-point-at-sexp-start</a>))
        ((<a id='4235' tid='4236' class='u'>=</a> <a id='4237' tid='4238' class='u'>n</a> <a id='4239' tid='4240' class='u'>0</a>) (<a id='4241' tid='4242' class='u'>point</a>))
        ((<a id='4243' tid='4244' class='u'>&gt;</a> <a id='4245' tid='4246' class='u'>n</a> <a id='4247' tid='4248' class='u'>0</a>) (<a id='4249' tid='4250' class='u'>paredit-point-at-sexp-end</a>))))

(<a id='4255' tid='4256' class='u'>defun</a> <a id='4257' tid='4258' class='u'>paredit-point-at-sexp-start</a> ()
  <span class='d'>(forward-sexp)</span>
  <span class='d'>(backward-sexp)</span>
  <span class='d'>(point)</span>)

(<a id='4251' tid='4252' class='u'>defun</a> <a id='4253' tid='4254' class='u'>paredit-point-at-sexp-end</a> ()
  <span class='d'>(backward-sexp)</span>
  <span class='d'>(forward-sexp)</span>
  <span class='d'>(point)</span>)

<a id='4925' tid='4926' class='u'>;;;; Initialization
</a>
(<a id='4927' tid='4928' class='u'>paredit-define-keys</a>)
(<a id='4929' tid='4930' class='u'>paredit-annotate-mode-with-examples</a>)
(<a id='4931' tid='4932' class='u'>paredit-annotate-functions-with-examples</a>)

(<a id='4933' tid='4934' class='u'>provide</a> <a id='4935' tid='4936' class='u'>&#39;</a><a id='4937' tid='4938' class='u'>paredit</a>)

</pre>
</div>
<div id="right" class="src">
<pre>
<a id='rightstart' tid='leftstart'></a>
<span class='i'>;;; paredit.el --- minor mode for editing parentheses  -*- Mode: Emacs-Lisp -*-
</span>
<span class='i'>;; Copyright (C) 2005--2010 Taylor R. Campbell
</span>
<span class='i'>;; Author: Taylor R. Campbell
</span><span class='i'>;; Version: 22
</span><span class='i'>;; Created: 2005-07-31
</span><span class='i'>;; Keywords: lisp
</span>
<span class='i'>;; Paredit is free software: you can redistribute it and/or modify it
</span><span class='i'>;; under the terms of the GNU General Public License as published by
</span><span class='i'>;; the Free Software Foundation, either version 3 of the License, or
</span><span class='i'>;; (at your option) any later version.
</span><span class='i'>;;
</span><span class='i'>;; Paredit is distributed in the hope that it will be useful, but
</span><span class='i'>;; WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span class='i'>;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><span class='i'>;; GNU General Public License for more details.
</span><span class='i'>;;
</span><span class='i'>;; You should have received a copy of the GNU General Public License
</span><span class='i'>;; along with paredit.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
</span>
<span class='i'>;;; This file is permanently stored at
</span><span class='i'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-22.el&gt;.
</span><a id='4628' tid='4627' class='u'>;;;
</a><span class='i'>;;; The currently released version of paredit is available at
</span><span class='i'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.el&gt;.
</span><span class='i'>;;;
</span><span class='i'>;;; The latest beta version of paredit is available at
</span><span class='i'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.
</span><span class='i'>;;;
</span><span class='i'>;;; Release notes are available at
</span><span class='i'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.release&gt;.
</span>
<span class='i'>;;; Install paredit by placing `paredit.el&#39; in `/path/to/elisp&#39;, a
</span><span class='i'>;;; directory of your choice, and adding to your .emacs file:
</span><span class='i'>;;;
</span><span class='i'>;;;   (add-to-list &#39;load-path &quot;/path/to/elisp&quot;)
</span><span class='i'>;;;   (autoload &#39;enable-paredit-mode &quot;paredit&quot;
</span><span class='i'>;;;     &quot;Turn on pseudo-structural editing of Lisp code.&quot;
</span><span class='i'>;;;     t)
</span><span class='i'>;;;
</span><span class='i'>;;; Enable Paredit Mode on the fly with `M-x enable-paredit-mode RET&#39;,
</span><span class='i'>;;; or always enable it in a major mode `M&#39; (e.g., `lisp&#39;) with:
</span><span class='i'>;;;
</span><span class='i'>;;;   (add-hook M-mode-hook &#39;enable-paredit-mode)
</span><span class='i'>;;;
</span><span class='i'>;;; Customize paredit using `eval-after-load&#39;:
</span><span class='i'>;;;
</span><span class='i'>;;;   (eval-after-load &#39;paredit
</span><span class='i'>;;;     &#39;(progn ...redefine keys, &c....))
</span><span class='i'>;;;
</span><span class='i'>;;; Paredit should run in GNU Emacs 21 or later and XEmacs 21.5 or
</span><span class='i'>;;; later.  Paredit is highly unlikely to work in earlier versions of
</span><span class='i'>;;; GNU Emacs, and it may have obscure problems in earlier versions of
</span><span class='i'>;;; XEmacs due to the way its syntax parser reports conditions, as a
</span><span class='i'>;;; result of which the code that uses the syntax parser must mask all
</span><span class='i'>;;; error conditions, not just those generated by the syntax parser.
</span><a id='4630' tid='4629' class='u'>;;;
</a><span class='i'>;;; Questions, bug reports, comments, feature suggestions, &c., may be
</span><span class='i'>;;; addressed via email to the author&#39;s surname at mumble.net or via
</span><span class='i'>;;; IRC to the user named Riastradh on irc.freenode.net in the #paredit
</span><span class='i'>;;; channel.
</span><span class='i'>;;;
</span><span class='i'>;;; Please contact the author rather than forking your own versions, to
</span><span class='i'>;;; prevent the dissemination of random variants floating about the
</span><span class='i'>;;; internet unbeknownst to the author.  Laziness is not an excuse:
</span><span class='i'>;;; your laziness costs me confusion and time trying to support
</span><span class='i'>;;; paredit, so if you fork paredit, you make the world a worse place.
</span><span class='i'>;;;
</span><span class='i'>;;; *** WARNING *** IMPORTANT *** DO NOT SUBMIT BUGS BEFORE READING ***
</span><a id='4632' tid='4631' class='u'>;;;
</a><span class='i'>;;; If you plan to submit a bug report, where some sequence of keys in
</span><span class='i'>;;; Paredit Mode, or some sequence of paredit commands, doesn&#39;t do what
</span><span class='i'>;;; you wanted, then it is helpful to isolate an example in a very
</span><span class='i'>;;; small buffer, and it is **ABSOLUTELY**ESSENTIAL** that you supply,
</span><span class='i'>;;; along with the sequence of keys or commands,
</span><a id='4634' tid='4633' class='u'>;;;
</a><span class='i'>;;;   (1) the version of Emacs,
</span><span class='i'>;;;   (2) the version of paredit.el[*], and
</span><span class='i'>;;;   (3) the **COMPLETE** state of the buffer used to reproduce the
</span><span class='i'>;;;       problem, including major mode, minor modes, local key
</span><span class='i'>;;;       bindings, entire contents of the buffer, leading line breaks
</span><span class='i'>;;;       or spaces, &c.
</span><span class='i'>;;;
</span><span class='i'>;;; It is often extremely difficult to reproduce problems, especially
</span><span class='i'>;;; with commands such as `paredit-kill&#39;.  If you do not supply **ALL**
</span><span class='i'>;;; of this information, then it is highly probable that I cannot
</span><span class='i'>;;; reproduce your problem no matter how hard I try, and the effect of
</span><span class='i'>;;; submitting a bug without this information is only to waste your
</span><span class='i'>;;; time and mine.  So, please, include all of the above information.
</span><span class='i'>;;;
</span><span class='i'>;;; [*] If you are using a beta version of paredit, be sure that you
</span><span class='i'>;;;     are using the *latest* edition of the beta version, available
</span><span class='i'>;;;     at &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.  If you
</span><span class='i'>;;;     are not using a beta version, then upgrade either to that or to
</span><span class='i'>;;;     the latest release version; I cannot support older versions,
</span><span class='i'>;;;     and I can&#39;t fathom any reason why you might be using them.  So
</span><span class='i'>;;;     the answer to item (2) should be either `release&#39; or `beta&#39;.
</span>
<span class='i'>;;; The paredit minor mode, Paredit Mode, binds a number of simple
</span><span class='i'>;;; keys, notably `(&#39;, `)&#39;, `&quot;&#39;, and `\&#39;, to commands that more
</span><span class='i'>;;; carefully insert S-expression structures in the buffer.  The
</span><span class='i'>;;; parenthesis delimiter keys (round or square) are defined to insert
</span><span class='i'>;;; parenthesis pairs and move past the closing delimiter,
</span><span class='i'>;;; respectively; the double-quote key is multiplexed to do both, and
</span><span class='i'>;;; also to insert an escape if within a string; and backslashes prompt
</span><span class='i'>;;; the user for the next character to input, because a lone backslash
</span><span class='i'>;;; can break structure inadvertently.  These all have their ordinary
</span><span class='i'>;;; behaviour when inside comments, and, outside comments, if truly
</span><span class='i'>;;; necessary, you can insert them literally with `C-q&#39;.
</span><span class='i'>;;;
</span><span class='i'>;;; The key bindings are designed so that when typing new code in
</span><span class='i'>;;; Paredit Mode, you can generally use exactly the same keystrokes as
</span><span class='i'>;;; you would have used without Paredit Mode.  Earlier versions of
</span><span class='i'>;;; paredit.el did not conform to this, because Paredit Mode bound `)&#39;
</span><span class='i'>;;; to a command that would insert a newline.  Now `)&#39; is bound to a
</span><span class='i'>;;; command that does not insert a newline, and `M-)&#39; is bound to the
</span><span class='i'>;;; command that inserts a newline.  To revert to the former behaviour,
</span><span class='i'>;;; add the following forms to an `eval-after-load&#39; form for paredit.el
</span><span class='i'>;;; in your .emacs file:
</span><span class='i'>;;;
</span><span class='i'>;;;   (define-key paredit-mode-map (kbd &quot;)&quot;)
</span><span class='i'>;;;     &#39;paredit-close-round-and-newline)
</span><span class='i'>;;;   (define-key paredit-mode-map (kbd &quot;M-)&quot;)
</span><span class='i'>;;;     &#39;paredit-close-round)
</span><span class='i'>;;;
</span><span class='i'>;;; Paredit Mode also binds the usual keys for deleting and killing, so
</span><span class='i'>;;; that they will not destroy any S-expression structure by killing or
</span><span class='i'>;;; deleting only one side of a parenthesis or quote pair.  If the
</span><span class='i'>;;; point is on a closing delimiter, `DEL&#39; will move left over it; if
</span><span class='i'>;;; it is on an opening delimiter, `C-d&#39; will move right over it.  Only
</span><span class='i'>;;; if the point is between a pair of delimiters will `C-d&#39; or `DEL&#39;
</span><span class='i'>;;; delete them, and in that case it will delete both simultaneously.
</span><span class='i'>;;; `M-d&#39; and `M-DEL&#39; kill words, but skip over any S-expression
</span><span class='i'>;;; structure.  `C-k&#39; kills from the start of the line, either to the
</span><span class='i'>;;; line&#39;s end, if it contains only balanced expressions; to the first
</span><span class='i'>;;; closing delimiter, if the point is within a form that ends on the
</span><span class='i'>;;; line; or up to the end of the last expression that starts on the
</span><span class='i'>;;; line after the point.
</span><span class='i'>;;;
</span><span class='i'>;;; The behaviour of the commands for deleting and killing can be
</span><span class='i'>;;; overridden by passing a `C-u&#39; prefix argument: `C-u DEL&#39; will
</span><span class='i'>;;; delete a character backward, `C-u C-d&#39; will delete a character
</span><span class='i'>;;; forward, and `C-u C-k&#39; will kill text from the point to the end of
</span><span class='i'>;;; the line, irrespective of the S-expression structure in the buffer.
</span><span class='i'>;;; This can be used to fix mistakes in a buffer, but should generally
</span><span class='i'>;;; be avoided.
</span><span class='i'>;;;
</span><span class='i'>;;; Paredit performs automatic reindentation as locally as possible, to
</span><span class='i'>;;; avoid interfering with custom indentation used elsewhere in some
</span><span class='i'>;;; S-expression.  Only the advanced S-expression manipulation commands
</span><span class='i'>;;; automatically reindent, and only the forms that were immediately
</span><span class='i'>;;; operated upon (and their subforms).
</span><span class='i'>;;;
</span><span class='i'>;;; This code is written for clarity, not efficiency.  It frequently
</span><span class='i'>;;; walks over S-expressions redundantly.  If you have problems with
</span><span class='i'>;;; the time it takes to execute some of the commands, let me know, but
</span><span class='i'>;;; first be sure that what you&#39;re doing is reasonable: it is
</span><span class='i'>;;; preferable to avoid immense S-expressions in code anyway.
</span>
<span class='i'>;;; This assumes Unix-style LF line endings.
</span>
<span class='i'>(defconst paredit-version 22)</span>
<span class='i'>(defconst paredit-beta-p nil)</span>

(<a id='668' tid='667' class='m'>eval-and-compile</a>

  (<a id='654' tid='653' class='m'>defun</a> <a id='656' tid='655' class='m'>paredit-xemacs-p</a> ()
    <span class='i'>;; No idea where I got this definition from.  Edward O&#39;Connor
</span>    <span class='i'>;; (hober in #emacs) suggested the current definition.
</span>    <a id='658' tid='657' class='m'>;;   (and (boundp &#39;running-xemacs)
</a>    <a id='660' tid='659' class='m'>;;        running-xemacs)
</a>    (<a id='662' tid='661' class='m'>featurep</a> <a id='664' tid='663' class='m'>&#39;</a><a id='666' tid='665' class='m'>xemacs</a>))

  (<a id='614' tid='613' class='m'>defun</a> <a id='616' tid='615' class='m'>paredit-gnu-emacs-p</a> ()
    <span class='i'>;++ This could probably be improved.
</span>    (<a id='618' tid='617' class='m'>not</a> (<a id='620' tid='619' class='m'>paredit-xemacs-p</a>)))

  (<a id='670' tid='669' class='m'>defmacro</a> <a id='672' tid='671' class='m'>xcond</a> (<a id='674' tid='673' class='m'>&rest</a> <a id='676' tid='675' class='m'>clauses</a>)
    <a id='678' tid='677' class='m'>&quot;Exhaustive COND.
Signal an error if no clause matches.&quot;</a>
    <a id='680' tid='679' class='m'>`</a>(<a id='682' tid='681' class='m'>cond</a> <a id='684' tid='683' class='m'>,</a><a id='686' tid='685' class='m'>@clauses</a>
           (<a id='688' tid='687' class='m'>t</a> (<a id='690' tid='689' class='m'>error</a> <a id='692' tid='691' class='m'>&quot;XCOND lost.&quot;</a>))))

  (<a id='694' tid='693' class='m'>defalias</a> <a id='696' tid='695' class='m'>&#39;</a><a id='698' tid='697' class='m'>paredit-warn</a> (<a id='700' tid='699' class='m'>if</a> (<a id='702' tid='701' class='m'>fboundp</a> <a id='704' tid='703' class='m'>&#39;</a><a id='706' tid='705' class='m'>warn</a>) <a id='708' tid='707' class='m'>&#39;</a><a id='710' tid='709' class='m'>warn</a> <a id='712' tid='711' class='m'>&#39;</a><a id='714' tid='713' class='m'>message</a>))

  (<a id='622' tid='621' class='m'>defvar</a> <a id='624' tid='623' class='m'>paredit-sexp-error-type</a>
    (<a id='626' tid='625' class='m'>with-temp-buffer</a>
      (<a id='628' tid='627' class='m'>insert</a> <a id='630' tid='629' class='m'>&quot;(&quot;</a>)
      (<a id='632' tid='631' class='m'>condition-case</a> <a id='634' tid='633' class='m'>condition</a>
          (<a id='636' tid='635' class='m'>backward-sexp</a>)
        (<a id='638' tid='637' class='m'>error</a> (<span class='i'>if</span> (<a id='640' tid='639' class='m'>eq</a> (<a id='642' tid='641' class='m'>car</a> <a id='644' tid='643' class='m'>condition</a>) <a id='646' tid='645' class='m'>&#39;</a><a id='648' tid='647' class='m'>error</a>)
                   <span class='i'>(paredit-warn &quot;%s%s%s%s%s&quot;
                                 &quot;Paredit is unable to discriminate&quot;
                                 &quot; S-expression parse errors from&quot;
                                 &quot; other errors. &quot;
                                 &quot; This may cause obscure problems. &quot;
                                 &quot; Please upgrade Emacs.&quot;)</span>)
               (<a id='650' tid='649' class='m'>car</a> <a id='652' tid='651' class='m'>condition</a>)))))

  (<a id='716' tid='715' class='m'>defmacro</a> <a id='718' tid='717' class='m'>paredit-handle-sexp-errors</a> (<a id='720' tid='719' class='m'>body</a> <a id='722' tid='721' class='m'>&rest</a> <a id='724' tid='723' class='m'>handler</a>)
    <a id='726' tid='725' class='m'>`</a>(<a id='728' tid='727' class='m'>condition-case</a> ()
         <a id='730' tid='729' class='m'>,</a><a id='732' tid='731' class='m'>body</a>
       (<a id='734' tid='733' class='m'>,</a><a id='736' tid='735' class='m'>paredit-sexp-error-type</a> <a id='738' tid='737' class='m'>,</a><a id='740' tid='739' class='m'>@handler</a>)))

  (<a id='742' tid='741' class='m'>put</a> <a id='744' tid='743' class='m'>&#39;</a><a id='746' tid='745' class='m'>paredit-handle-sexp-errors</a> <a id='748' tid='747' class='m'>&#39;</a><a id='750' tid='749' class='m'>lisp-indent-function</a> <a id='752' tid='751' class='m'>1</a>)

  (<a id='754' tid='753' class='m'>defmacro</a> <a id='756' tid='755' class='m'>paredit-ignore-sexp-errors</a> (<a id='758' tid='757' class='m'>&rest</a> <a id='760' tid='759' class='m'>body</a>)
    <a id='762' tid='761' class='m'>`</a>(<a id='764' tid='763' class='m'>paredit-handle-sexp-errors</a> (<a id='766' tid='765' class='m'>progn</a> <a id='768' tid='767' class='m'>,</a><a id='770' tid='769' class='m'>@body</a>)
       <a id='772' tid='771' class='m'>nil</a>))

  (<a id='774' tid='773' class='m'>put</a> <a id='776' tid='775' class='m'>&#39;</a><a id='778' tid='777' class='m'>paredit-ignore-sexp-errors</a> <a id='780' tid='779' class='m'>&#39;</a><a id='782' tid='781' class='m'>lisp-indent-function</a> <a id='784' tid='783' class='m'>0</a>)

  <a id='786' tid='785' class='m'>nil</a>)

<span class='i'>;;;; Minor Mode Definition
</span>
(<a id='4190' tid='4189' class='u'>defvar</a> <a id='4192' tid='4191' class='u'>paredit-mode-map</a> (<a id='4194' tid='4193' class='u'>make-sparse-keymap</a>)
  <a id='4196' tid='4195' class='u'>&quot;Keymap for the paredit minor mode.&quot;</a>)

<span class='i'>;;;###autoload
</span>(<a id='4120' tid='4119' class='u'>define-minor-mode</a> <a id='4122' tid='4121' class='u'>paredit-mode</a>
  <span class='i'>&quot;Minor mode for pseudo-structurally editing Lisp code.
With a prefix argument, enable Paredit Mode even if there are
  imbalanced parentheses in the buffer.
Paredit behaves badly if parentheses are imbalanced, so exercise
  caution when forcing Paredit Mode to be enabled, and consider
  fixing imbalanced parentheses instead.
\\&lt;paredit-mode-map&gt;&quot;</span>
  <a id='4124' tid='4123' class='u'>:lighter</a> <a id='4126' tid='4125' class='u'>&quot; Paredit&quot;</a>
  <a id='4128' tid='4127' class='u'>;; If we&#39;re enabling paredit-mode, the prefix to this code that
</a>  <a id='4130' tid='4129' class='u'>;; DEFINE-MINOR-MODE inserts will have already set PAREDIT-MODE to
</a>  <a id='4132' tid='4131' class='u'>;; true.  If this is the case, then first check the parentheses, and
</a>  <a id='4134' tid='4133' class='u'>;; if there are any imbalanced ones we must inhibit the activation of
</a>  <a id='4136' tid='4135' class='u'>;; paredit mode.  We skip the check, though, if the user supplied a
</a>  <a id='4138' tid='4137' class='u'>;; prefix argument interactively.
</a>  (<a id='4140' tid='4139' class='u'>if</a> (<a id='4142' tid='4141' class='u'>and</a> <a id='4144' tid='4143' class='u'>paredit-mode</a>
           (<a id='4146' tid='4145' class='u'>not</a> <a id='4148' tid='4147' class='u'>current-prefix-arg</a>))
      (<a id='4150' tid='4149' class='u'>if</a> (<a id='4152' tid='4151' class='u'>not</a> (<a id='4154' tid='4153' class='u'>fboundp</a> <a id='4156' tid='4155' class='u'>&#39;</a><a id='4158' tid='4157' class='u'>check-parens</a>))
          (<a id='4160' tid='4159' class='u'>paredit-warn</a> <a id='4162' tid='4161' class='u'>&quot;`check-parens&#39; is not defined; %s&quot;</a>
                        <a id='4164' tid='4163' class='u'>&quot;be careful of malformed S-expressions.&quot;</a>)
          (<a id='4166' tid='4165' class='u'>condition-case</a> <a id='4168' tid='4167' class='u'>condition</a>
              (<a id='4170' tid='4169' class='u'>check-parens</a>)
            (<a id='4172' tid='4171' class='u'>error</a> (<a id='4174' tid='4173' class='u'>setq</a> <a id='4176' tid='4175' class='u'>paredit-mode</a> <a id='4178' tid='4177' class='u'>nil</a>)
                   (<a id='4180' tid='4179' class='u'>signal</a> (<a id='4182' tid='4181' class='u'>car</a> <a id='4184' tid='4183' class='u'>condition</a>) (<a id='4186' tid='4185' class='u'>cdr</a> <a id='4188' tid='4187' class='u'>condition</a>)))))))

(<a id='1528' tid='1527' class='u'>defun</a> <a id='1530' tid='1529' class='u'>enable-paredit-mode</a> ()
  <span class='i'>&quot;Turn on pseudo-structural editing of Lisp code.&quot;</span>
  (<a id='1532' tid='1531' class='u'>interactive</a>)
  (<a id='1534' tid='1533' class='u'>paredit-mode</a> <a id='1536' tid='1535' class='u'>+1</a>))

(<a id='1518' tid='1517' class='u'>defun</a> <a id='1520' tid='1519' class='u'>disable-paredit-mode</a> ()
  <span class='i'>&quot;Turn off pseudo-structural editing of Lisp code.&quot;</span>
  (<a id='1522' tid='1521' class='u'>interactive</a>)
  (<a id='1524' tid='1523' class='u'>paredit-mode</a> <a id='1526' tid='1525' class='u'>-1</a>))

(<a id='1958' tid='1957' class='u'>defvar</a> <a id='1960' tid='1959' class='u'>paredit-backward-delete-key</a>
  (<a id='1962' tid='1961' class='u'>xcond</a> ((<a id='1964' tid='1963' class='u'>paredit-xemacs-p</a>)    <a id='1966' tid='1965' class='u'>&quot;BS&quot;</a>)
         ((<a id='1968' tid='1967' class='u'>paredit-gnu-emacs-p</a>) <a id='1970' tid='1969' class='u'>&quot;DEL&quot;</a>)))

(<a id='2596' tid='2595' class='u'>defvar</a> <a id='2598' tid='2597' class='u'>paredit-forward-delete-keys</a>
  (<a id='2600' tid='2599' class='u'>xcond</a> ((<a id='2602' tid='2601' class='u'>paredit-xemacs-p</a>)    <a id='2604' tid='2603' class='u'>&#39;</a>(<a id='2606' tid='2605' class='u'>&quot;DEL&quot;</a>))
         ((<a id='2608' tid='2607' class='u'>paredit-gnu-emacs-p</a>) <a id='2610' tid='2609' class='u'>&#39;</a>(<a id='2612' tid='2611' class='u'>&quot;&lt;delete&gt;&quot;</a> <a id='2614' tid='2613' class='u'>&quot;&lt;deletechar&gt;&quot;</a>))))

<span class='i'>;;;; Paredit Keys
</span>
<span class='i'>;;; Separating the definition and initialization of this variable
</span><span class='i'>;;; simplifies the development of paredit, since re-evaluating DEFVAR
</span><span class='i'>;;; forms doesn&#39;t actually do anything.
</span>
(<a id='2200' tid='2199' class='u'>defvar</a> <a id='2202' tid='2201' class='u'>paredit-commands</a> <a id='2204' tid='2203' class='u'>nil</a>
  <a id='2206' tid='2205' class='u'>&quot;List of paredit commands with their keys and examples.&quot;</a>)

<span class='i'>;;; Each specifier is of the form:
</span><span class='i'>;;;   (key[s] function (example-input example-output) ...)
</span><span class='i'>;;; where key[s] is either a single string suitable for passing to KBD
</span><span class='i'>;;; or a list of such strings.  Entries in this list may also just be
</span><span class='i'>;;; strings, in which case they are headings for the next entries.
</span>
(<a id='788' tid='787' class='m'>progn</a> (<a id='790' tid='789' class='m'>setq</a> <a id='792' tid='791' class='m'>paredit-commands</a>
 <a id='794' tid='793' class='m'>`</a>(
   <span class='i'>&quot;Basic Insertion Commands&quot;</span>
   <span class='i'>(&quot;(&quot;         paredit-open-round
                (&quot;(a b |c d)&quot;
                 &quot;(a b (|) c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar (|baz\&quot; quux)&quot;))</span>
   <span class='i'>(&quot;)&quot;         paredit-close-round
                (&quot;(a b |c   )&quot; &quot;(a b c)|&quot;)
                (&quot;; Hello,| world!&quot;
                 &quot;; Hello,)| world!&quot;))</span>
   <span class='i'>(&quot;M-)&quot;       paredit-close-round-and-newline
                (&quot;(defun f (x|  ))&quot;
                 &quot;(defun f (x)\n  |)&quot;)
                (&quot;; (Foo.|&quot;
                 &quot;; (Foo.)|&quot;))</span>
   <span class='i'>(&quot;[&quot;         paredit-open-square
                (&quot;(a b |c d)&quot;
                 &quot;(a b [|] c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar [baz\&quot; quux)&quot;))</span>
   <span class='i'>(&quot;]&quot;         paredit-close-square
                (&quot;(define-key keymap [frob|  ] &#39;frobnicate)&quot;
                 &quot;(define-key keymap [frob]| &#39;frobnicate)&quot;)
                (&quot;; [Bar.|&quot;
                 &quot;; [Bar.]|&quot;))</span>
   (<a id='796' tid='795' class='m'>&quot;\&quot;&quot;</a>        <a id='798' tid='797' class='m'>paredit-doublequote</a>
                (<a id='800' tid='799' class='m'>&quot;(frob grovel |full lexical)&quot;</a>
                 <a id='802' tid='801' class='m'>&quot;(frob grovel \&quot;|\&quot; full lexical)&quot;</a>)
                (<a id='804' tid='803' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='806' tid='805' class='m'>&quot;(foo \&quot;bar \\\&quot;|baz\&quot; quux)&quot;</a>))
   (<a id='496' tid='495' class='m'>&quot;M-\&quot;&quot;</a>      <a id='498' tid='497' class='m'>paredit-meta-doublequote</a>
                (<a id='500' tid='499' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='502' tid='501' class='m'>&quot;(foo \&quot;bar baz\&quot;\n     |quux)&quot;</a>)
                (<a id='504' tid='503' class='m'>&quot;(foo |(bar #\\x \&quot;baz \\\\ quux\&quot;) zot)&quot;</a>
                 <a id='506' tid='505' class='m'>,</a>(<a id='508' tid='507' class='m'>concat</a> <a id='510' tid='509' class='m'>&quot;(foo \&quot;|(bar #\\\\x \\\&quot;baz \\\\&quot;</a>
                          <a id='512' tid='511' class='m'>&quot;\\\\ quux\\\&quot;)\&quot; zot)&quot;</a>)))
   (<a id='394' tid='393' class='m'>&quot;\\&quot;</a>        <a id='396' tid='395' class='m'>paredit-backslash</a>
                (<a id='398' tid='397' class='m'>&quot;(string #|)\n  ; Escaping character... (x)&quot;</a>
                 <a id='400' tid='399' class='m'>&quot;(string #\\x|)&quot;</a>)
                (<a id='402' tid='401' class='m'>&quot;\&quot;foo|bar\&quot;\n  ; Escaping character... (\&quot;)&quot;</a>
                 <a id='404' tid='403' class='m'>&quot;\&quot;foo\\\&quot;|bar\&quot;&quot;</a>))
   <span class='i'>(&quot;;&quot;         paredit-semicolon
                (&quot;|(frob grovel)&quot;
                 &quot;;|(frob grovel)&quot;)
                (&quot;(frob |grovel)&quot;
                 &quot;(frob ;grovel\n)&quot;)
                (&quot;(frob |grovel (bloit\n               zargh))&quot;
                 &quot;(frob ;|grovel\n (bloit\n  zargh))&quot;)
                (&quot;(frob grovel)          |&quot;
                 &quot;(frob grovel)          ;|&quot;))</span>
   (<a id='306' tid='305' class='m'>&quot;M-;&quot;</a>       <a id='308' tid='307' class='m'>paredit-comment-dwim</a>
                (<a id='310' tid='309' class='m'>&quot;(foo |bar)   ; baz&quot;</a>
                 <a id='312' tid='311' class='m'>&quot;(foo bar)                               ; |baz&quot;</a>)
                (<a id='314' tid='313' class='m'>&quot;(frob grovel)|&quot;</a>
                 <a id='316' tid='315' class='m'>&quot;(frob grovel)                           ;|&quot;</a>)
                (<a id='318' tid='317' class='m'>&quot;    (foo bar)\n|\n    (baz quux)&quot;</a>
                 <a id='320' tid='319' class='m'>&quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;</a>)
                (<a id='322' tid='321' class='m'>&quot;    (foo bar) |(baz quux)&quot;</a>
                 <a id='324' tid='323' class='m'>&quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;</a>)
                (<a id='326' tid='325' class='m'>&quot;|(defun hello-world ...)&quot;</a>
                 <a id='328' tid='327' class='m'>&quot;;;; |\n(defun hello-world ...)&quot;</a>))

   (<a id='262' tid='261' class='m'>&quot;C-j&quot;</a>       <a id='264' tid='263' class='m'>paredit-newline</a>
                (<a id='266' tid='265' class='m'>&quot;(let ((n (frobbotz))) |(display (+ n 1)\nport))&quot;</a>
                 <a id='268' tid='267' class='m'>,</a>(<a id='270' tid='269' class='m'>concat</a> <a id='272' tid='271' class='m'>&quot;(let ((n (frobbotz)))&quot;</a>
                          <a id='274' tid='273' class='m'>&quot;\n  |(display (+ n 1)&quot;</a>
                          <a id='276' tid='275' class='m'>&quot;\n            port))&quot;</a>)))

   <span class='i'>&quot;Deleting & Killing&quot;</span>
   ((<a id='218' tid='217' class='m'>&quot;C-d&quot;</a> <a id='220' tid='219' class='m'>,</a><a id='222' tid='221' class='m'>@paredit-forward-delete-keys</a>)
                <a id='224' tid='223' class='m'>paredit-forward-delete</a>
                (<a id='226' tid='225' class='m'>&quot;(quu|x \&quot;zot\&quot;)&quot;</a> <a id='228' tid='227' class='m'>&quot;(quu| \&quot;zot\&quot;)&quot;</a>)
                (<a id='230' tid='229' class='m'>&quot;(quux |\&quot;zot\&quot;)&quot;</a>
                 <a id='232' tid='231' class='m'>&quot;(quux \&quot;|zot\&quot;)&quot;</a>
                 <a id='234' tid='233' class='m'>&quot;(quux \&quot;|ot\&quot;)&quot;</a>)
                (<a id='236' tid='235' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='238' tid='237' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='240' tid='239' class='m'>&quot;|(foo bar)&quot;</a> <a id='242' tid='241' class='m'>&quot;(|foo bar)&quot;</a>))
   (<a id='194' tid='193' class='m'>,</a><a id='196' tid='195' class='m'>paredit-backward-delete-key</a>
                <a id='198' tid='197' class='m'>paredit-backward-delete</a>
                (<a id='200' tid='199' class='m'>&quot;(\&quot;zot\&quot; q|uux)&quot;</a> <a id='202' tid='201' class='m'>&quot;(\&quot;zot\&quot; |uux)&quot;</a>)
                (<a id='204' tid='203' class='m'>&quot;(\&quot;zot\&quot;| quux)&quot;</a>
                 <a id='206' tid='205' class='m'>&quot;(\&quot;zot|\&quot; quux)&quot;</a>
                 <a id='208' tid='207' class='m'>&quot;(\&quot;zo|\&quot; quux)&quot;</a>)
                (<a id='210' tid='209' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='212' tid='211' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='214' tid='213' class='m'>&quot;(foo bar)|&quot;</a> <a id='216' tid='215' class='m'>&quot;(foo bar|)&quot;</a>))
   (<a id='174' tid='173' class='m'>&quot;C-k&quot;</a>       <a id='176' tid='175' class='m'>paredit-kill</a>
                (<a id='178' tid='177' class='m'>&quot;(foo bar)|     ; Useless comment!&quot;</a>
                 <a id='180' tid='179' class='m'>&quot;(foo bar)|&quot;</a>)
                (<a id='182' tid='181' class='m'>&quot;(|foo bar)     ; Useful comment!&quot;</a>
                 <a id='184' tid='183' class='m'>&quot;(|)     ; Useful comment!&quot;</a>)
                (<a id='186' tid='185' class='m'>&quot;|(foo bar)     ; Useless line!&quot;</a>
                 <a id='188' tid='187' class='m'>&quot;|&quot;</a>)
                (<a id='190' tid='189' class='m'>&quot;(foo \&quot;|bar baz\&quot;\n     quux)&quot;</a>
                 <a id='192' tid='191' class='m'>&quot;(foo \&quot;|\&quot;\n     quux)&quot;</a>))
   (<a id='156' tid='155' class='m'>&quot;M-d&quot;</a>       <a id='158' tid='157' class='m'>paredit-forward-kill-word</a>
                (<a id='160' tid='159' class='m'>&quot;|(foo bar)    ; baz&quot;</a>
                 <a id='162' tid='161' class='m'>&quot;(| bar)    ; baz&quot;</a>
                 <a id='164' tid='163' class='m'>&quot;(|)    ; baz&quot;</a>
                 <a id='166' tid='165' class='m'>&quot;()    ;|&quot;</a>)
                (<a id='168' tid='167' class='m'>&quot;;;;| Frobnicate\n(defun frobnicate ...)&quot;</a>
                 <a id='170' tid='169' class='m'>&quot;;;;|\n(defun frobnicate ...)&quot;</a>
                 <a id='172' tid='171' class='m'>&quot;;;;\n(| frobnicate ...)&quot;</a>))
   (<a id='136' tid='135' class='m'>,</a>(<a id='138' tid='137' class='m'>concat</a> <a id='140' tid='139' class='m'>&quot;M-&quot;</a> <a id='142' tid='141' class='m'>paredit-backward-delete-key</a>)
                <a id='144' tid='143' class='m'>paredit-backward-kill-word</a>
                (<a id='146' tid='145' class='m'>&quot;(foo bar)    ; baz\n(quux)|&quot;</a>
                 <a id='148' tid='147' class='m'>&quot;(foo bar)    ; baz\n(|)&quot;</a>
                 <a id='150' tid='149' class='m'>&quot;(foo bar)    ; |\n()&quot;</a>
                 <a id='152' tid='151' class='m'>&quot;(foo |)    ; \n()&quot;</a>
                 <a id='154' tid='153' class='m'>&quot;(|)    ; \n()&quot;</a>))

   <span class='i'>&quot;Movement & Navigation&quot;</span>
   (<a id='124' tid='123' class='m'>&quot;C-M-f&quot;</a>     <a id='126' tid='125' class='m'>paredit-forward</a>
                (<a id='128' tid='127' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>
                 <a id='130' tid='129' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>)
                (<a id='132' tid='131' class='m'>&quot;(foo (bar)|)&quot;</a>
                 <a id='134' tid='133' class='m'>&quot;(foo (bar))|&quot;</a>))
   (<a id='112' tid='111' class='m'>&quot;C-M-b&quot;</a>     <a id='114' tid='113' class='m'>paredit-backward</a>
                (<a id='116' tid='115' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>
                 <a id='118' tid='117' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>)
                (<a id='120' tid='119' class='m'>&quot;(|(foo) bar)&quot;</a>
                 <a id='122' tid='121' class='m'>&quot;|((foo) bar)&quot;</a>))
   <span class='i'>(&quot;C-M-u&quot;     paredit-backward-up)</span>
   <span class='i'>(&quot;C-M-d&quot;     paredit-forward-down)</span>
   <span class='i'>(&quot;C-M-p&quot;     paredit-backward-down)</span>  <span class='i'>; Built-in, these are FORWARD-
</span>   <span class='i'>(&quot;C-M-n&quot;     paredit-forward-up)</span>     <span class='i'>; & BACKWARD-LIST, which have
</span>                                        <span class='i'>; no need given C-M-f & C-M-b.
</span>
   <span class='i'>&quot;Depth-Changing Commands&quot;</span>
   <span class='i'>(&quot;M-(&quot;       paredit-wrap-round
                (&quot;(foo |bar baz)&quot;
                 &quot;(foo (|bar) baz)&quot;))</span>
   <span class='i'>(&quot;M-s&quot;       paredit-splice-sexp
                (&quot;(foo (bar| baz) quux)&quot;
                 &quot;(foo bar| baz quux)&quot;))</span>
   ((<a id='102' tid='101' class='m'>&quot;M-&lt;up&gt;&quot;</a> <a id='104' tid='103' class='m'>&quot;ESC &lt;up&gt;&quot;</a>)
                <a id='106' tid='105' class='m'>paredit-splice-sexp-killing-backward</a>
                (<a id='108' tid='107' class='m'>&quot;(foo (let ((x 5)) |(sqrt n)) bar)&quot;</a>
                 <a id='110' tid='109' class='m'>&quot;(foo (sqrt n) bar)&quot;</a>))
   ((<a id='92' tid='91' class='m'>&quot;M-&lt;down&gt;&quot;</a> <a id='94' tid='93' class='m'>&quot;ESC &lt;down&gt;&quot;</a>)
                <a id='96' tid='95' class='m'>paredit-splice-sexp-killing-forward</a>
                (<a id='98' tid='97' class='m'>&quot;(a (b c| d e) f)&quot;</a>
                 <a id='100' tid='99' class='m'>&quot;(a b c f)&quot;</a>))
   (<a id='82' tid='81' class='m'>&quot;M-r&quot;</a>       <a id='84' tid='83' class='m'>paredit-raise-sexp</a>
                (<a id='86' tid='85' class='m'>&quot;(dynamic-wind in (lambda () |body) out)&quot;</a>
                 <a id='88' tid='87' class='m'>&quot;(dynamic-wind in |body out)&quot;</a>
                 <a id='90' tid='89' class='m'>&quot;|body&quot;</a>))

   <span class='i'>&quot;Barfage & Slurpage&quot;</span>
   ((<a id='68' tid='67' class='m'>&quot;C-)&quot;</a> <a id='70' tid='69' class='m'>&quot;C-&lt;right&gt;&quot;</a>)
                <a id='72' tid='71' class='m'>paredit-forward-slurp-sexp</a>
                (<a id='74' tid='73' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>
                 <a id='76' tid='75' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>)
                (<a id='78' tid='77' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='80' tid='79' class='m'>&quot;(a b ((c| d) e) f)&quot;</a>))
   ((<a id='58' tid='57' class='m'>&quot;C-}&quot;</a> <a id='60' tid='59' class='m'>&quot;C-&lt;left&gt;&quot;</a>)
                <a id='62' tid='61' class='m'>paredit-forward-barf-sexp</a>
                (<a id='64' tid='63' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>
                 <a id='66' tid='65' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>))
   ((<a id='42' tid='41' class='m'>&quot;C-(&quot;</a> <a id='44' tid='43' class='m'>&quot;C-M-&lt;left&gt;&quot;</a> <a id='46' tid='45' class='m'>&quot;ESC C-&lt;left&gt;&quot;</a>)
                <a id='48' tid='47' class='m'>paredit-backward-slurp-sexp</a>
                (<a id='50' tid='49' class='m'>&quot;(foo bar (baz| quux) zot)&quot;</a>
                 <a id='52' tid='51' class='m'>&quot;(foo (bar baz| quux) zot)&quot;</a>)
                (<a id='54' tid='53' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='56' tid='55' class='m'>&quot;(a (b (c| d)) e f)&quot;</a>))
   ((<a id='30' tid='29' class='m'>&quot;C-{&quot;</a> <a id='32' tid='31' class='m'>&quot;C-M-&lt;right&gt;&quot;</a> <a id='34' tid='33' class='m'>&quot;ESC C-&lt;right&gt;&quot;</a>)
                <a id='36' tid='35' class='m'>paredit-backward-barf-sexp</a>
                (<a id='38' tid='37' class='m'>&quot;(foo (bar baz |quux) zot)&quot;</a>
                 <a id='40' tid='39' class='m'>&quot;(foo bar (baz |quux) zot)&quot;</a>))

   <span class='i'>&quot;Miscellaneous Commands&quot;</span>
   (<a id='18' tid='17' class='m'>&quot;M-S&quot;</a>       <a id='20' tid='19' class='m'>paredit-split-sexp</a>
                (<a id='22' tid='21' class='m'>&quot;(hello| world)&quot;</a>
                 <a id='24' tid='23' class='m'>&quot;(hello)| (world)&quot;</a>)
                (<a id='26' tid='25' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>
                 <a id='28' tid='27' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>))
   (<a id='2' tid='1' class='m'>&quot;M-J&quot;</a>       <a id='4' tid='3' class='m'>paredit-join-sexps</a>
                (<a id='6' tid='5' class='m'>&quot;(hello)| (world)&quot;</a>
                 <a id='8' tid='7' class='m'>&quot;(hello| world)&quot;</a>)
                (<a id='10' tid='9' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>
                 <a id='12' tid='11' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>)
                (<a id='14' tid='13' class='m'>&quot;hello-\n|  world&quot;</a>
                 <a id='16' tid='15' class='m'>&quot;hello-|world&quot;</a>))
   <span class='i'>(&quot;C-c C-M-l&quot; paredit-recentre-on-sexp)</span>
   <span class='i'>(&quot;M-q&quot;       paredit-reindent-defun)</span>
   ))
       <a id='808' tid='807' class='m'>nil</a>)                             <span class='i'>; end of PROGN
</span>
<span class='i'>;;;;; Command Examples
</span>
(<a id='4636' tid='4635' class='u'>eval-and-compile</a>
  (<a id='4638' tid='4637' class='u'>defmacro</a> <a id='4640' tid='4639' class='u'>paredit-do-commands</a> (<a id='4642' tid='4641' class='u'>vars</a> <a id='4644' tid='4643' class='u'>string-case</a> <a id='4646' tid='4645' class='u'>&rest</a> <a id='4648' tid='4647' class='u'>body</a>)
    (<a id='4650' tid='4649' class='u'>let</a> ((<a id='4652' tid='4651' class='u'>spec</a>     (<a id='4654' tid='4653' class='u'>nth</a> <a id='4656' tid='4655' class='u'>0</a> <a id='4658' tid='4657' class='u'>vars</a>))
          (<a id='4660' tid='4659' class='u'>keys</a>     (<a id='4662' tid='4661' class='u'>nth</a> <a id='4664' tid='4663' class='u'>1</a> <a id='4666' tid='4665' class='u'>vars</a>))
          (<a id='4668' tid='4667' class='u'>fn</a>       (<a id='4670' tid='4669' class='u'>nth</a> <a id='4672' tid='4671' class='u'>2</a> <a id='4674' tid='4673' class='u'>vars</a>))
          (<a id='4676' tid='4675' class='u'>examples</a> (<a id='4678' tid='4677' class='u'>nth</a> <a id='4680' tid='4679' class='u'>3</a> <a id='4682' tid='4681' class='u'>vars</a>)))
      <a id='4684' tid='4683' class='u'>`</a>(<a id='4686' tid='4685' class='u'>dolist</a> (<a id='4688' tid='4687' class='u'>,</a><a id='4690' tid='4689' class='u'>spec</a> <a id='4692' tid='4691' class='u'>paredit-commands</a>)
         (<a id='4694' tid='4693' class='u'>if</a> (<a id='4696' tid='4695' class='u'>stringp</a> <a id='4698' tid='4697' class='u'>,</a><a id='4700' tid='4699' class='u'>spec</a>)
             <a id='4702' tid='4701' class='u'>,</a><a id='4704' tid='4703' class='u'>string-case</a>
           (<a id='4706' tid='4705' class='u'>let</a> ((<a id='4708' tid='4707' class='u'>,</a><a id='4710' tid='4709' class='u'>keys</a> (<a id='4712' tid='4711' class='u'>let</a> ((<a id='4714' tid='4713' class='u'>k</a> (<a id='4716' tid='4715' class='u'>car</a> <a id='4718' tid='4717' class='u'>,</a><a id='4720' tid='4719' class='u'>spec</a>)))
                          (<a id='4722' tid='4721' class='u'>cond</a> ((<a id='4724' tid='4723' class='u'>stringp</a> <a id='4726' tid='4725' class='u'>k</a>) (<a id='4728' tid='4727' class='u'>list</a> <a id='4730' tid='4729' class='u'>k</a>))
                                ((<a id='4732' tid='4731' class='u'>listp</a> <a id='4734' tid='4733' class='u'>k</a>) <a id='4736' tid='4735' class='u'>k</a>)
                                (<a id='4738' tid='4737' class='u'>t</a> (<a id='4740' tid='4739' class='u'>error</a> <a id='4742' tid='4741' class='u'>&quot;Invalid paredit command %s.&quot;</a>
                                          <a id='4744' tid='4743' class='u'>,</a><a id='4746' tid='4745' class='u'>spec</a>)))))
                 (<a id='4748' tid='4747' class='u'>,</a><a id='4750' tid='4749' class='u'>fn</a> (<a id='4752' tid='4751' class='u'>cadr</a> <a id='4754' tid='4753' class='u'>,</a><a id='4756' tid='4755' class='u'>spec</a>))
                 (<a id='4758' tid='4757' class='u'>,</a><a id='4760' tid='4759' class='u'>examples</a> (<a id='4762' tid='4761' class='u'>cddr</a> <a id='4764' tid='4763' class='u'>,</a><a id='4766' tid='4765' class='u'>spec</a>)))
             <a id='4768' tid='4767' class='u'>,</a><a id='4770' tid='4769' class='u'>@body</a>)))))

  (<a id='4772' tid='4771' class='u'>put</a> <a id='4774' tid='4773' class='u'>&#39;</a><a id='4776' tid='4775' class='u'>paredit-do-commands</a> <a id='4778' tid='4777' class='u'>&#39;</a><a id='4780' tid='4779' class='u'>lisp-indent-function</a> <a id='4782' tid='4781' class='u'>2</a>))

(<a id='2248' tid='2247' class='u'>defun</a> <a id='2250' tid='2249' class='u'>paredit-define-keys</a> ()
  (<a id='2252' tid='2251' class='u'>paredit-do-commands</a> (<a id='2254' tid='2253' class='u'>spec</a> <a id='2256' tid='2255' class='u'>keys</a> <a id='2258' tid='2257' class='u'>fn</a> <a id='2260' tid='2259' class='u'>examples</a>)
      <a id='2262' tid='2261' class='u'>nil</a>       <a id='2264' tid='2263' class='u'>; string case
</a>    (<a id='2266' tid='2265' class='u'>dolist</a> (<a id='2268' tid='2267' class='u'>key</a> <a id='2270' tid='2269' class='u'>keys</a>)
      (<a id='2272' tid='2271' class='u'>define-key</a> <a id='2274' tid='2273' class='u'>paredit-mode-map</a> (<a id='2276' tid='2275' class='u'>read-kbd-macro</a> <a id='2278' tid='2277' class='u'>key</a>) <a id='2280' tid='2279' class='u'>fn</a>))))

(<a id='3106' tid='3105' class='u'>defun</a> <a id='3108' tid='3107' class='u'>paredit-function-documentation</a> (<a id='3110' tid='3109' class='u'>fn</a>)
  (<a id='3112' tid='3111' class='u'>let</a> ((<a id='3114' tid='3113' class='u'>original-doc</a> (<a id='3116' tid='3115' class='u'>get</a> <a id='3118' tid='3117' class='u'>fn</a> <a id='3120' tid='3119' class='u'>&#39;</a><a id='3122' tid='3121' class='u'>paredit-original-documentation</a>))
        (<a id='3124' tid='3123' class='u'>doc</a> (<a id='3126' tid='3125' class='u'>documentation</a> <a id='3128' tid='3127' class='u'>fn</a> <a id='3130' tid='3129' class='u'>&#39;</a><a id='3132' tid='3131' class='u'>function-documentation</a>)))
    (<a id='3134' tid='3133' class='u'>or</a> <a id='3136' tid='3135' class='u'>original-doc</a>
        (<a id='3138' tid='3137' class='u'>progn</a> (<a id='3140' tid='3139' class='u'>put</a> <a id='3142' tid='3141' class='u'>fn</a> <a id='3144' tid='3143' class='u'>&#39;</a><a id='3146' tid='3145' class='u'>paredit-original-documentation</a> <a id='3148' tid='3147' class='u'>doc</a>)
               <a id='3150' tid='3149' class='u'>doc</a>))))

(<a id='1604' tid='1603' class='u'>defun</a> <a id='1606' tid='1605' class='u'>paredit-annotate-mode-with-examples</a> ()
  (<a id='1608' tid='1607' class='u'>let</a> ((<a id='1610' tid='1609' class='u'>contents</a>
         (<a id='1612' tid='1611' class='u'>list</a> (<a id='1614' tid='1613' class='u'>paredit-function-documentation</a> <a id='1616' tid='1615' class='u'>&#39;</a><a id='1618' tid='1617' class='u'>paredit-mode</a>))))
    (<a id='1620' tid='1619' class='u'>paredit-do-commands</a> (<a id='1622' tid='1621' class='u'>spec</a> <a id='1624' tid='1623' class='u'>keys</a> <a id='1626' tid='1625' class='u'>fn</a> <a id='1628' tid='1627' class='u'>examples</a>)
        (<a id='1630' tid='1629' class='u'>push</a> (<a id='1632' tid='1631' class='u'>concat</a> <a id='1634' tid='1633' class='u'>&quot;\n\n&quot;</a> <a id='1636' tid='1635' class='u'>spec</a> <a id='1638' tid='1637' class='u'>&quot;\n&quot;</a>)
              <a id='1640' tid='1639' class='u'>contents</a>)
      (<a id='1642' tid='1641' class='u'>let</a> ((<a id='1644' tid='1643' class='u'>name</a> (<a id='1646' tid='1645' class='u'>symbol-name</a> <a id='1648' tid='1647' class='u'>fn</a>)))
        (<a id='1650' tid='1649' class='u'>if</a> (<a id='1652' tid='1651' class='u'>string-match</a> (<a id='1654' tid='1653' class='u'>symbol-name</a> <a id='1656' tid='1655' class='u'>&#39;</a><a id='1658' tid='1657' class='u'>paredit-</a>) <a id='1660' tid='1659' class='u'>name</a>)
            (<a id='1662' tid='1661' class='u'>push</a> (<a id='1664' tid='1663' class='u'>concat</a> <a id='1666' tid='1665' class='u'>&quot;\n\n\\[&quot;</a> <a id='1668' tid='1667' class='u'>name</a> <a id='1670' tid='1669' class='u'>&quot;]\t&quot;</a> <a id='1672' tid='1671' class='u'>name</a>
                          (<a id='1674' tid='1673' class='u'>if</a> <a id='1676' tid='1675' class='u'>examples</a>
                              (<a id='1678' tid='1677' class='u'>mapconcat</a> (<a id='1680' tid='1679' class='u'>lambda</a> (<a id='1682' tid='1681' class='u'>example</a>)
                                           (<a id='1684' tid='1683' class='u'>concat</a>
                                            <a id='1686' tid='1685' class='u'>&quot;\n&quot;</a>
                                            (<a id='1688' tid='1687' class='u'>mapconcat</a> <a id='1690' tid='1689' class='u'>&#39;</a><a id='1692' tid='1691' class='u'>identity</a>
                                                       <a id='1694' tid='1693' class='u'>example</a>
                                                       <a id='1696' tid='1695' class='u'>&quot;\n  ---&gt;\n&quot;</a>)
                                            <a id='1698' tid='1697' class='u'>&quot;\n&quot;</a>))
                                         <a id='1700' tid='1699' class='u'>examples</a>
                                         <a id='1702' tid='1701' class='u'>&quot;&quot;</a>)
                              <a id='1704' tid='1703' class='u'>&quot;\n  (no examples)\n&quot;</a>))
                  <a id='1706' tid='1705' class='u'>contents</a>))))
    (<a id='1708' tid='1707' class='u'>put</a> <a id='1710' tid='1709' class='u'>&#39;</a><a id='1712' tid='1711' class='u'>paredit-mode</a> <a id='1714' tid='1713' class='u'>&#39;</a><a id='1716' tid='1715' class='u'>function-documentation</a>
         (<a id='1718' tid='1717' class='u'>apply</a> <a id='1720' tid='1719' class='u'>&#39;</a><a id='1722' tid='1721' class='u'>concat</a> (<a id='1724' tid='1723' class='u'>reverse</a> <a id='1726' tid='1725' class='u'>contents</a>))))
  <a id='1728' tid='1727' class='u'>;; PUT returns the huge string we just constructed, which we don&#39;t
</a>  <a id='1730' tid='1729' class='u'>;; want it to return.
</a>  <a id='1732' tid='1731' class='u'>nil</a>)

(<a id='1538' tid='1537' class='u'>defun</a> <a id='1540' tid='1539' class='u'>paredit-annotate-functions-with-examples</a> ()
  (<a id='1542' tid='1541' class='u'>paredit-do-commands</a> (<a id='1544' tid='1543' class='u'>spec</a> <a id='1546' tid='1545' class='u'>keys</a> <a id='1548' tid='1547' class='u'>fn</a> <a id='1550' tid='1549' class='u'>examples</a>)
      <a id='1552' tid='1551' class='u'>nil</a>       <a id='1554' tid='1553' class='u'>; string case
</a>    (<a id='1556' tid='1555' class='u'>put</a> <a id='1558' tid='1557' class='u'>fn</a> <a id='1560' tid='1559' class='u'>&#39;</a><a id='1562' tid='1561' class='u'>function-documentation</a>
         (<a id='1564' tid='1563' class='u'>concat</a> (<a id='1566' tid='1565' class='u'>paredit-function-documentation</a> <a id='1568' tid='1567' class='u'>fn</a>)
                 <a id='1570' tid='1569' class='u'>&quot;\n\n\\&lt;paredit-mode-map&gt;\\[&quot;</a> (<a id='1572' tid='1571' class='u'>symbol-name</a> <a id='1574' tid='1573' class='u'>fn</a>) <a id='1576' tid='1575' class='u'>&quot;]\n&quot;</a>
                 (<a id='1578' tid='1577' class='u'>mapconcat</a> (<a id='1580' tid='1579' class='u'>lambda</a> (<a id='1582' tid='1581' class='u'>example</a>)
                              (<a id='1584' tid='1583' class='u'>concat</a> <a id='1586' tid='1585' class='u'>&quot;\n&quot;</a>
                                      (<a id='1588' tid='1587' class='u'>mapconcat</a> <a id='1590' tid='1589' class='u'>&#39;</a><a id='1592' tid='1591' class='u'>identity</a>
                                                 <a id='1594' tid='1593' class='u'>example</a>
                                                 <a id='1596' tid='1595' class='u'>&quot;\n  -&gt;\n&quot;</a>)
                                      <a id='1598' tid='1597' class='u'>&quot;\n&quot;</a>))
                            <a id='1600' tid='1599' class='u'>examples</a>
                            <a id='1602' tid='1601' class='u'>&quot;&quot;</a>)))))

<a id='4784' tid='4783' class='u'>;;;;; HTML Examples
</a>
(<a id='3326' tid='3325' class='u'>defun</a> <a id='3328' tid='3327' class='u'>paredit-insert-html-examples</a> ()
  <a id='3330' tid='3329' class='u'>&quot;Insert HTML for a paredit quick reference table.&quot;</a>
  (<a id='3332' tid='3331' class='u'>interactive</a>)
  (<a id='3334' tid='3333' class='u'>let</a> ((<a id='3336' tid='3335' class='u'>insert-lines</a>
         (<a id='3338' tid='3337' class='u'>lambda</a> (<a id='3340' tid='3339' class='u'>&rest</a> <a id='3342' tid='3341' class='u'>lines</a>)
           (<a id='3344' tid='3343' class='u'>mapc</a> (<a id='3346' tid='3345' class='u'>lambda</a> (<a id='3348' tid='3347' class='u'>line</a>) (<a id='3350' tid='3349' class='u'>insert</a> <a id='3352' tid='3351' class='u'>line</a>) (<a id='3354' tid='3353' class='u'>newline</a>))
                 <a id='3356' tid='3355' class='u'>lines</a>)))
        (<a id='3358' tid='3357' class='u'>html-keys</a>
         (<a id='3360' tid='3359' class='u'>lambda</a> (<a id='3362' tid='3361' class='u'>keys</a>)
           (<a id='3364' tid='3363' class='u'>mapconcat</a> <a id='3366' tid='3365' class='u'>&#39;</a><a id='3368' tid='3367' class='u'>paredit-html-quote</a> <a id='3370' tid='3369' class='u'>keys</a> <a id='3372' tid='3371' class='u'>&quot;, &quot;</a>)))
        (<a id='3374' tid='3373' class='u'>html-example</a>
         (<a id='3376' tid='3375' class='u'>lambda</a> (<a id='3378' tid='3377' class='u'>example</a>)
           (<a id='3380' tid='3379' class='u'>concat</a> <a id='3382' tid='3381' class='u'>&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>
                   (<a id='3384' tid='3383' class='u'>mapconcat</a> <a id='3386' tid='3385' class='u'>&#39;</a><a id='3388' tid='3387' class='u'>paredit-html-quote</a>
                              <a id='3390' tid='3389' class='u'>example</a>
                              (<a id='3392' tid='3391' class='u'>concat</a> <a id='3394' tid='3393' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&quot;</a>
                                      <a id='3396' tid='3395' class='u'>&quot;&nbsp;&nbsp;&nbsp;&nbsp;---&gt;&quot;</a>
                                      <a id='3398' tid='3397' class='u'>&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>))
                   <a id='3400' tid='3399' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</a>)))
        (<a id='3402' tid='3401' class='u'>firstp</a> <a id='3404' tid='3403' class='u'>t</a>))
    (<a id='3406' tid='3405' class='u'>paredit-do-commands</a> (<a id='3408' tid='3407' class='u'>spec</a> <a id='3410' tid='3409' class='u'>keys</a> <a id='3412' tid='3411' class='u'>fn</a> <a id='3414' tid='3413' class='u'>examples</a>)
        (<a id='3416' tid='3415' class='u'>progn</a> (<a id='3418' tid='3417' class='u'>if</a> (<a id='3420' tid='3419' class='u'>not</a> <a id='3422' tid='3421' class='u'>firstp</a>)
                   (<a id='3424' tid='3423' class='u'>insert</a> <a id='3426' tid='3425' class='u'>&quot;&lt;/table&gt;\n&quot;</a>)
                   (<a id='3428' tid='3427' class='u'>setq</a> <a id='3430' tid='3429' class='u'>firstp</a> <a id='3432' tid='3431' class='u'>nil</a>))
               (<a id='3434' tid='3433' class='u'>funcall</a> <a id='3436' tid='3435' class='u'>insert-lines</a>
                        (<a id='3438' tid='3437' class='u'>concat</a> <a id='3440' tid='3439' class='u'>&quot;&lt;h3&gt;&quot;</a> <a id='3442' tid='3441' class='u'>spec</a> <a id='3444' tid='3443' class='u'>&quot;&lt;/h3&gt;&quot;</a>)
                        <a id='3446' tid='3445' class='u'>&quot;&lt;table border=\&quot;1\&quot; cellpadding=\&quot;1\&quot;&gt;&quot;</a>
                        <a id='3448' tid='3447' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                        <a id='3450' tid='3449' class='u'>&quot;    &lt;th&gt;Command&lt;/th&gt;&quot;</a>
                        <a id='3452' tid='3451' class='u'>&quot;    &lt;th&gt;Keys&lt;/th&gt;&quot;</a>
                        <a id='3454' tid='3453' class='u'>&quot;    &lt;th&gt;Examples&lt;/th&gt;&quot;</a>
                        <a id='3456' tid='3455' class='u'>&quot;  &lt;/tr&gt;&quot;</a>))
      (<a id='3458' tid='3457' class='u'>let</a> ((<a id='3460' tid='3459' class='u'>name</a> (<a id='3462' tid='3461' class='u'>symbol-name</a> <a id='3464' tid='3463' class='u'>fn</a>)))
        (<a id='3466' tid='3465' class='u'>if</a> (<a id='3468' tid='3467' class='u'>string-match</a> (<a id='3470' tid='3469' class='u'>symbol-name</a> <a id='3472' tid='3471' class='u'>&#39;</a><a id='3474' tid='3473' class='u'>paredit-</a>) <a id='3476' tid='3475' class='u'>name</a>)
            (<a id='3478' tid='3477' class='u'>funcall</a> <a id='3480' tid='3479' class='u'>insert-lines</a>
                     <a id='3482' tid='3481' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                     (<a id='3484' tid='3483' class='u'>concat</a> <a id='3486' tid='3485' class='u'>&quot;    &lt;td&gt;&lt;tt&gt;&quot;</a> <a id='3488' tid='3487' class='u'>name</a> <a id='3490' tid='3489' class='u'>&quot;&lt;/tt&gt;&lt;/td&gt;&quot;</a>)
                     (<a id='3492' tid='3491' class='u'>concat</a> <a id='3494' tid='3493' class='u'>&quot;    &lt;td align=\&quot;center\&quot;&gt;&quot;</a>
                             (<a id='3496' tid='3495' class='u'>funcall</a> <a id='3498' tid='3497' class='u'>html-keys</a> <a id='3500' tid='3499' class='u'>keys</a>)
                             <a id='3502' tid='3501' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     (<a id='3504' tid='3503' class='u'>concat</a> <a id='3506' tid='3505' class='u'>&quot;    &lt;td&gt;&quot;</a>
                             (<a id='3508' tid='3507' class='u'>if</a> <a id='3510' tid='3509' class='u'>examples</a>
                                 (<a id='3512' tid='3511' class='u'>mapconcat</a> <a id='3514' tid='3513' class='u'>html-example</a> <a id='3516' tid='3515' class='u'>examples</a>
                                            <a id='3518' tid='3517' class='u'>&quot;&lt;hr&gt;&quot;</a>)
                                 <a id='3520' tid='3519' class='u'>&quot;(no examples)&quot;</a>)
                             <a id='3522' tid='3521' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     <a id='3524' tid='3523' class='u'>&quot;  &lt;/tr&gt;&quot;</a>)))))
  (<a id='3526' tid='3525' class='u'>insert</a> <a id='3528' tid='3527' class='u'>&quot;&lt;/table&gt;\n&quot;</a>))

(<a id='3152' tid='3151' class='u'>defun</a> <a id='3154' tid='3153' class='u'>paredit-html-quote</a> (<a id='3156' tid='3155' class='u'>string</a>)
  (<a id='3158' tid='3157' class='u'>with-temp-buffer</a>
    (<a id='3160' tid='3159' class='u'>dotimes</a> (<a id='3162' tid='3161' class='u'>i</a> (<a id='3164' tid='3163' class='u'>length</a> <a id='3166' tid='3165' class='u'>string</a>))
      (<a id='3168' tid='3167' class='u'>insert</a> (<a id='3170' tid='3169' class='u'>let</a> ((<a id='3172' tid='3171' class='u'>c</a> (<a id='3174' tid='3173' class='u'>elt</a> <a id='3176' tid='3175' class='u'>string</a> <a id='3178' tid='3177' class='u'>i</a>)))
                (<a id='3180' tid='3179' class='u'>cond</a> ((<a id='3182' tid='3181' class='u'>eq</a> <a id='3184' tid='3183' class='u'>c</a> <a id='3186' tid='3185' class='u'>?\&lt;</a>) <a id='3188' tid='3187' class='u'>&quot;&lt;&quot;</a>)
                      ((<a id='3190' tid='3189' class='u'>eq</a> <a id='3192' tid='3191' class='u'>c</a> <a id='3194' tid='3193' class='u'>?\&gt;</a>) <a id='3196' tid='3195' class='u'>&quot;&gt;&quot;</a>)
                      ((<a id='3198' tid='3197' class='u'>eq</a> <a id='3200' tid='3199' class='u'>c</a> <a id='3202' tid='3201' class='u'>?\&</a>) <a id='3204' tid='3203' class='u'>&quot;&amp;&quot;</a>)
                      ((<a id='3206' tid='3205' class='u'>eq</a> <a id='3208' tid='3207' class='u'>c</a> <a id='3210' tid='3209' class='u'>?\&#39;</a>) <a id='3212' tid='3211' class='u'>&quot;&apos;&quot;</a>)
                      ((<a id='3214' tid='3213' class='u'>eq</a> <a id='3216' tid='3215' class='u'>c</a> <a id='3218' tid='3217' class='u'>?\&quot;</a>) <a id='3220' tid='3219' class='u'>&quot;&quot;&quot;</a>)
                      (<a id='3222' tid='3221' class='u'>t</a> <a id='3224' tid='3223' class='u'>c</a>)))))
    (<a id='3226' tid='3225' class='u'>buffer-string</a>)))

<a id='4786' tid='4785' class='u'>;;;; Delimiter Insertion
</a>
(<a id='828' tid='827' class='m'>eval-and-compile</a>
  (<a id='810' tid='809' class='m'>defun</a> <a id='812' tid='811' class='m'>paredit-conc-name</a> (<a id='814' tid='813' class='m'>&rest</a> <a id='816' tid='815' class='m'>strings</a>)
    (<a id='818' tid='817' class='m'>intern</a> (<a id='820' tid='819' class='m'>apply</a> <a id='822' tid='821' class='m'>&#39;</a><a id='824' tid='823' class='m'>concat</a> <a id='826' tid='825' class='m'>strings</a>)))

  (<a id='830' tid='829' class='m'>defmacro</a> <a id='832' tid='831' class='m'>define-paredit-pair</a> (<a id='834' tid='833' class='m'>open</a> <a id='836' tid='835' class='m'>close</a> <a id='838' tid='837' class='m'>name</a>)
    <a id='840' tid='839' class='m'>`</a>(<span class='i'>progn</span>
       (<a id='842' tid='841' class='m'>defun</a> <a id='844' tid='843' class='m'>,</a>(<a id='846' tid='845' class='m'>paredit-conc-name</a> <a id='848' tid='847' class='m'>&quot;paredit-open-&quot;</a> <a id='850' tid='849' class='m'>name</a>) (<a id='852' tid='851' class='m'>&optional</a> <a id='854' tid='853' class='m'>n</a>)
         <a id='856' tid='855' class='m'>,</a>(<a id='858' tid='857' class='m'>concat</a> <a id='860' tid='859' class='m'>&quot;Insert a balanced &quot;</a> <a id='862' tid='861' class='m'>name</a> <a id='864' tid='863' class='m'>&quot; pair.
With a prefix argument N, put the closing &quot;</a> <a id='866' tid='865' class='m'>name</a> <a id='868' tid='867' class='m'>&quot; after N
  S-expressions forward.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  &quot;</a> <a id='870' tid='869' class='m'>name</a> <a id='872' tid='871' class='m'>&quot; pair around the region.
If in a string or a comment, insert a single &quot;</a> <a id='874' tid='873' class='m'>name</a> <a id='876' tid='875' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='878' tid='877' class='m'>interactive</a> <a id='880' tid='879' class='m'>&quot;P&quot;</a>)
         (<a id='882' tid='881' class='m'>cond</a> ((<a id='884' tid='883' class='m'>or</a> (<a id='886' tid='885' class='m'>paredit-in-string-p</a>)
                    (<a id='888' tid='887' class='m'>paredit-in-comment-p</a>))
                (<a id='890' tid='889' class='m'>insert</a> <a id='892' tid='891' class='m'>,</a><a id='894' tid='893' class='m'>open</a>))
               ((<a id='896' tid='895' class='m'>not</a> (<a id='898' tid='897' class='m'>paredit-in-char-p</a>))
                (<a id='900' tid='899' class='m'>paredit-insert-pair</a> <a id='902' tid='901' class='m'>n</a> <a id='904' tid='903' class='m'>,</a><a id='906' tid='905' class='m'>open</a> <a id='908' tid='907' class='m'>,</a><a id='910' tid='909' class='m'>close</a> <a id='912' tid='911' class='m'>&#39;</a><a id='914' tid='913' class='m'>goto-char</a>))))
       (<a id='514' tid='513' class='m'>defun</a> <a id='516' tid='515' class='m'>,</a>(<a id='518' tid='517' class='m'>paredit-conc-name</a> <a id='520' tid='519' class='m'>&quot;paredit-close-&quot;</a> <a id='522' tid='521' class='m'>name</a>) ()
         <a id='524' tid='523' class='m'>,</a>(<a id='526' tid='525' class='m'>concat</a> <a id='528' tid='527' class='m'>&quot;Move past one closing delimiter and reindent.
\(Agnostic to the specific closing delimiter.)
If in a string or comment, insert a single closing &quot;</a> <a id='530' tid='529' class='m'>name</a> <a id='532' tid='531' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='534' tid='533' class='m'>interactive</a>)
         (<a id='536' tid='535' class='m'>paredit-move-past-close</a> <a id='538' tid='537' class='m'>,</a><a id='540' tid='539' class='m'>close</a>))
       (<a id='406' tid='405' class='m'>defun</a> <a id='408' tid='407' class='m'>,</a>(<a id='410' tid='409' class='m'>paredit-conc-name</a> <a id='412' tid='411' class='m'>&quot;paredit-close-&quot;</a> <a id='414' tid='413' class='m'>name</a> <a id='416' tid='415' class='m'>&quot;-and-newline&quot;</a>) ()
         <a id='418' tid='417' class='m'>,</a>(<a id='420' tid='419' class='m'>concat</a> <a id='422' tid='421' class='m'>&quot;Move past one closing delimiter, add a newline,&quot;</a>
                  <a id='424' tid='423' class='m'>&quot; and reindent.
If there was a margin comment after the closing delimiter, preserve it
  on the same line.&quot;</a>)
         (<a id='426' tid='425' class='m'>interactive</a>)
         (<a id='428' tid='427' class='m'>paredit-move-past-close-and-newline</a> <a id='430' tid='429' class='m'>,</a><a id='432' tid='431' class='m'>close</a>))
       <span class='i'>(defun ,(paredit-conc-name &quot;paredit-wrap-&quot; name)
           (&optional argument)
         ,(concat &quot;Wrap the following S-expression.
See `paredit-wrap-sexp&#39; for more details.&quot;)
         (interactive &quot;P&quot;)
         (paredit-wrap-sexp argument ,open ,close))</span>
       <span class='i'>(add-to-list &#39;paredit-wrap-commands
                    &#39;,(paredit-conc-name &quot;paredit-wrap-&quot; name))</span>)))

<span class='i'>(defvar paredit-wrap-commands &#39;(paredit-wrap-sexp)
  &quot;List of paredit commands that wrap S-expressions.
Used by `paredit-yank-pop&#39;; for internal paredit use only.&quot;)</span>

<span class='i'>(define-paredit-pair ?\( ?\) &quot;round&quot;)</span>
<span class='i'>(define-paredit-pair ?\[ ?\] &quot;square&quot;)</span>
<span class='i'>(define-paredit-pair ?\{ ?\} &quot;curly&quot;)</span>
<span class='i'>(define-paredit-pair ?\&lt; ?\&gt; &quot;angled&quot;)</span>

<span class='i'>;;; Aliases for the old names.
</span>
<span class='i'>(defalias &#39;paredit-open-parenthesis &#39;paredit-open-round)</span>
<span class='i'>(defalias &#39;paredit-close-parenthesis &#39;paredit-close-round)</span>
<span class='i'>(defalias &#39;paredit-close-parenthesis-and-newline
  &#39;paredit-close-round-and-newline)</span>

<span class='i'>(defalias &#39;paredit-open-bracket &#39;paredit-open-square)</span>
<span class='i'>(defalias &#39;paredit-close-bracket &#39;paredit-close-square)</span>
<span class='i'>(defalias &#39;paredit-close-bracket-and-newline
  &#39;paredit-close-square-and-newline)</span>

(<a id='4198' tid='4197' class='u'>defun</a> <a id='4200' tid='4199' class='u'>paredit-move-past-close</a> (<a id='4202' tid='4201' class='u'>close</a>)
  (<span class='i'>cond</span> ((<a id='916' tid='915' class='m'>or</a> (<a id='918' tid='917' class='m'>paredit-in-string-p</a>)
             (<a id='920' tid='919' class='m'>paredit-in-comment-p</a>))
         (<a id='922' tid='921' class='m'>insert</a> <a id='924' tid='923' class='m'>close</a>))
        <span class='i'>((not (paredit-in-char-p))
         (paredit-move-past-close-and-reindent close)
         (paredit-blink-paren-match nil))</span>))

(<a id='4204' tid='4203' class='u'>defun</a> <a id='4206' tid='4205' class='u'>paredit-move-past-close-and-newline</a> (<a id='4208' tid='4207' class='u'>close</a>)
  (<span class='i'>if</span> <span class='i'>(or (paredit-in-string-p)
          (paredit-in-comment-p))</span>
      <span class='i'>(insert close)</span>
    <span class='i'>(if (paredit-in-char-p) (forward-char))</span>
    <span class='i'>(paredit-move-past-close-and-reindent close)</span>
    (<a id='926' tid='925' class='m'>let</a> ((<a id='928' tid='927' class='m'>comment.point</a> (<a id='930' tid='929' class='m'>paredit-find-comment-on-line</a>)))
      (<a id='932' tid='931' class='m'>newline</a>)
      (<a id='934' tid='933' class='m'>if</a> <a id='936' tid='935' class='m'>comment.point</a>
          (<a id='938' tid='937' class='m'>save-excursion</a>
            (<a id='940' tid='939' class='m'>forward-line</a> <a id='942' tid='941' class='m'>-1</a>)
            (<a id='944' tid='943' class='m'>end-of-line</a>)
            (<a id='946' tid='945' class='m'>indent-to</a> (<a id='948' tid='947' class='m'>cdr</a> <a id='950' tid='949' class='m'>comment.point</a>))
            (<a id='952' tid='951' class='m'>insert</a> (<a id='954' tid='953' class='m'>car</a> <a id='956' tid='955' class='m'>comment.point</a>)))))
    <span class='i'>(lisp-indent-line)</span>
    <span class='i'>(paredit-ignore-sexp-errors (indent-sexp))</span>
    <span class='i'>(paredit-blink-paren-match t)</span>))

(<a id='2430' tid='2429' class='u'>defun</a> <a id='2432' tid='2431' class='u'>paredit-find-comment-on-line</a> ()
  <span class='i'>&quot;Find a margin comment on the current line.
Return nil if there is no such comment or if there is anything but
  whitespace until such a comment.
If such a comment exists, delete the comment (including all leading
  whitespace) and return a cons whose car is the comment as a string
  and whose cdr is the point of the comment&#39;s initial semicolon,
  relative to the start of the line.&quot;</span>
  (<span class='i'>save-excursion</span>
    <span class='i'>(paredit-skip-whitespace t (point-at-eol))</span>
    (<span class='i'>and</span> <span class='i'>(eq ?\; (char-after))</span>
         <span class='i'>(not (eq ?\; (char-after (1+ (point)))))</span>
         <span class='i'>(not (or (paredit-in-string-p)
                  (paredit-in-char-p)))</span>
         (<a id='958' tid='957' class='m'>let*</a> ((<a id='960' tid='959' class='m'>start</a>                  <span class='i'>;Move to before the semicolon.
</span>                 (<a id='962' tid='961' class='m'>progn</a> (<a id='964' tid='963' class='m'>backward-char</a>) (<a id='966' tid='965' class='m'>point</a>)))
                (<a id='968' tid='967' class='m'>comment</a>
                 (<a id='970' tid='969' class='m'>buffer-substring</a> <a id='972' tid='971' class='m'>start</a> (<a id='974' tid='973' class='m'>point-at-eol</a>))))
           (<a id='976' tid='975' class='m'>paredit-skip-whitespace</a> <a id='978' tid='977' class='m'>nil</a> (<a id='980' tid='979' class='m'>point-at-bol</a>))
           (<a id='982' tid='981' class='m'>delete-region</a> (<a id='984' tid='983' class='m'>point</a>) (<a id='986' tid='985' class='m'>point-at-eol</a>))
           (<a id='988' tid='987' class='m'>cons</a> <a id='990' tid='989' class='m'>comment</a> (<a id='992' tid='991' class='m'>-</a> <a id='994' tid='993' class='m'>start</a> (<a id='996' tid='995' class='m'>point-at-bol</a>)))))))

(<a id='3530' tid='3529' class='u'>defun</a> <a id='3532' tid='3531' class='u'>paredit-insert-pair</a> (<a id='3534' tid='3533' class='u'>n</a> <a id='3536' tid='3535' class='u'>open</a> <a id='3538' tid='3537' class='u'>close</a> <a id='3540' tid='3539' class='u'>forward</a>)
  (<a id='3542' tid='3541' class='u'>let*</a> ((<a id='3544' tid='3543' class='u'>regionp</a>
          (<a id='3546' tid='3545' class='u'>and</a> (<a id='3548' tid='3547' class='u'>paredit-region-active-p</a>)
               (<a id='3550' tid='3549' class='u'>paredit-region-safe-for-insert-p</a>)))
         (<a id='3552' tid='3551' class='u'>end</a>
          (<a id='3554' tid='3553' class='u'>and</a> <a id='3556' tid='3555' class='u'>regionp</a>
               (<a id='3558' tid='3557' class='u'>not</a> <a id='3560' tid='3559' class='u'>n</a>)
               (<a id='3562' tid='3561' class='u'>prog1</a> (<a id='3564' tid='3563' class='u'>region-end</a>) (<a id='3566' tid='3565' class='u'>goto-char</a> (<a id='3568' tid='3567' class='u'>region-beginning</a>))))))
    (<a id='3570' tid='3569' class='u'>let</a> ((<a id='3572' tid='3571' class='u'>spacep</a> (<a id='3574' tid='3573' class='u'>paredit-space-for-delimiter-p</a> <a id='3576' tid='3575' class='u'>nil</a> <a id='3578' tid='3577' class='u'>open</a>)))
      (<a id='3580' tid='3579' class='u'>if</a> <a id='3582' tid='3581' class='u'>spacep</a> (<a id='3584' tid='3583' class='u'>insert</a> <a id='3586' tid='3585' class='u'>&quot; &quot;</a>))
      (<a id='3588' tid='3587' class='u'>insert</a> <a id='3590' tid='3589' class='u'>open</a>)
      (<a id='3592' tid='3591' class='u'>save-excursion</a>
        <a id='3594' tid='3593' class='u'>;; Move past the desired region.
</a>        (<a id='3596' tid='3595' class='u'>cond</a> (<a id='3598' tid='3597' class='u'>n</a> (<a id='3600' tid='3599' class='u'>funcall</a> <a id='3602' tid='3601' class='u'>forward</a>
                          (<a id='3604' tid='3603' class='u'>save-excursion</a>
                            (<a id='3606' tid='3605' class='u'>forward-sexp</a> (<a id='3608' tid='3607' class='u'>prefix-numeric-value</a> <a id='3610' tid='3609' class='u'>n</a>))
                            (<a id='3612' tid='3611' class='u'>point</a>))))
              (<a id='3614' tid='3613' class='u'>regionp</a> (<a id='3616' tid='3615' class='u'>funcall</a> <a id='3618' tid='3617' class='u'>forward</a> (<a id='3620' tid='3619' class='u'>+</a> <a id='3622' tid='3621' class='u'>end</a> (<a id='3624' tid='3623' class='u'>if</a> <a id='3626' tid='3625' class='u'>spacep</a> <a id='3628' tid='3627' class='u'>2</a> <a id='3630' tid='3629' class='u'>1</a>)))))
        (<a id='3632' tid='3631' class='u'>insert</a> <a id='3634' tid='3633' class='u'>close</a>)
        (<a id='3636' tid='3635' class='u'>if</a> (<a id='3638' tid='3637' class='u'>paredit-space-for-delimiter-p</a> <a id='3640' tid='3639' class='u'>t</a> <a id='3642' tid='3641' class='u'>close</a>)
            (<a id='3644' tid='3643' class='u'>insert</a> <a id='3646' tid='3645' class='u'>&quot; &quot;</a>))))))

(<a id='4330' tid='4329' class='u'>defun</a> <a id='4332' tid='4331' class='u'>paredit-region-safe-for-insert-p</a> ()
  (<a id='4334' tid='4333' class='u'>save-excursion</a>
    (<a id='4336' tid='4335' class='u'>let</a> ((<a id='4338' tid='4337' class='u'>beginning</a> (<a id='4340' tid='4339' class='u'>region-beginning</a>))
          (<a id='4342' tid='4341' class='u'>end</a> (<a id='4344' tid='4343' class='u'>region-end</a>)))
      (<a id='4346' tid='4345' class='u'>goto-char</a> <a id='4348' tid='4347' class='u'>beginning</a>)
      (<a id='4350' tid='4349' class='u'>let*</a> ((<a id='4352' tid='4351' class='u'>beginning-state</a> (<a id='4354' tid='4353' class='u'>paredit-current-parse-state</a>))
             (<a id='4356' tid='4355' class='u'>end-state</a>
              (<a id='4358' tid='4357' class='u'>parse-partial-sexp</a> <a id='4360' tid='4359' class='u'>beginning</a> <a id='4362' tid='4361' class='u'>end</a> <a id='4364' tid='4363' class='u'>nil</a> <a id='4366' tid='4365' class='u'>nil</a> <a id='4368' tid='4367' class='u'>beginning-state</a>)))
        (<a id='4370' tid='4369' class='u'>and</a> (<a id='4372' tid='4371' class='u'>=</a>  (<a id='4374' tid='4373' class='u'>nth</a> <a id='4376' tid='4375' class='u'>0</a> <a id='4378' tid='4377' class='u'>beginning-state</a>)   <a id='4380' tid='4379' class='u'>; 0. depth in parens
</a>                 (<a id='4382' tid='4381' class='u'>nth</a> <a id='4384' tid='4383' class='u'>0</a> <a id='4386' tid='4385' class='u'>end-state</a>))
             (<a id='4388' tid='4387' class='u'>eq</a> (<a id='4390' tid='4389' class='u'>nth</a> <a id='4392' tid='4391' class='u'>3</a> <a id='4394' tid='4393' class='u'>beginning-state</a>)   <a id='4396' tid='4395' class='u'>; 3. non-nil if inside a
</a>                 (<a id='4398' tid='4397' class='u'>nth</a> <a id='4400' tid='4399' class='u'>3</a> <a id='4402' tid='4401' class='u'>end-state</a>))        <a id='4404' tid='4403' class='u'>;    string
</a>             (<a id='4406' tid='4405' class='u'>eq</a> (<a id='4408' tid='4407' class='u'>nth</a> <a id='4410' tid='4409' class='u'>4</a> <a id='4412' tid='4411' class='u'>beginning-state</a>)   <a id='4414' tid='4413' class='u'>; 4. comment status, yada
</a>                 (<a id='4416' tid='4415' class='u'>nth</a> <a id='4418' tid='4417' class='u'>4</a> <a id='4420' tid='4419' class='u'>end-state</a>))
             (<a id='4422' tid='4421' class='u'>eq</a> (<a id='4424' tid='4423' class='u'>nth</a> <a id='4426' tid='4425' class='u'>5</a> <a id='4428' tid='4427' class='u'>beginning-state</a>)   <a id='4430' tid='4429' class='u'>; 5. t if following char
</a>                 (<a id='4432' tid='4431' class='u'>nth</a> <a id='4434' tid='4433' class='u'>5</a> <a id='4436' tid='4435' class='u'>end-state</a>)))))))   <span class='i'>;    quote
</span>
<span class='i'>(defvar paredit-space-for-delimiter-predicates nil
  &quot;List of predicates for whether to put space by delimiter at point.
Each predicate is a function that is is applied to two arguments, ENDP
  and DELIMITER, and that returns a boolean saying whether to put a
  space next to the delimiter -- before the delimiter if ENDP is false,
  after the delimiter if ENDP is true.
If any predicate returns false, no space is inserted: every predicate
  has veto power.
Each predicate may assume that the point is not at the beginning of the
  buffer, if ENDP is false, or at the end of the buffer, if ENDP is
  true; and that the point is not preceded, if ENDP is false, or
  followed, if ENDP is true, by a word or symbol constituent, a quote,
  or the delimiter matching DELIMITER.
Each predicate should examine only text before the point, if ENDP is
  false, or only text after the point, if ENDP is true.&quot;)</span>

(<a id='4478' tid='4477' class='u'>defun</a> <a id='4480' tid='4479' class='u'>paredit-space-for-delimiter-p</a> (<a id='4482' tid='4481' class='u'>endp</a> <a id='4484' tid='4483' class='u'>delimiter</a>)
  <a id='4486' tid='4485' class='u'>;; If at the buffer limit, don&#39;t insert a space.  If there is a word,
</a>  <a id='4488' tid='4487' class='u'>;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a
</a>  <a id='4490' tid='4489' class='u'>;; close when want an open the string or an open when we want to
</a>  <a id='4492' tid='4491' class='u'>;; close the string), do insert a space.
</a>  (<span class='i'>and</span> (<a id='998' tid='997' class='m'>not</a> (<a id='1000' tid='999' class='m'>if</a> <a id='1002' tid='1001' class='m'>endp</a> (<a id='1004' tid='1003' class='m'>eobp</a>) (<a id='1006' tid='1005' class='m'>bobp</a>)))
       (<a id='434' tid='433' class='m'>memq</a> (<a id='542' tid='541' class='m'>char-syntax</a> (<a id='544' tid='543' class='m'>if</a> <a id='546' tid='545' class='m'>endp</a> (<a id='548' tid='547' class='m'>char-after</a>) (<a id='550' tid='549' class='m'>char-before</a>)))
             (<span class='i'>list</span> <span class='i'>?w</span> <span class='i'>?_</span> <span class='i'>?\&quot;</span>
                   (<a id='436' tid='435' class='m'>let</a> ((<a id='438' tid='437' class='m'>matching</a> (<a id='440' tid='439' class='m'>matching-paren</a> <a id='442' tid='441' class='m'>delimiter</a>)))
                     (<a id='444' tid='443' class='m'>and</a> <a id='446' tid='445' class='m'>matching</a> (<a id='448' tid='447' class='m'>char-syntax</a> <a id='450' tid='449' class='m'>matching</a>)))
                   <span class='i'>(and (not endp)
                        (eq ?\&quot; (char-syntax delimiter))
                        ?\) )</span>))
       <span class='i'>(catch &#39;exit
         (dolist (predicate paredit-space-for-delimiter-predicates)
           (if (not (funcall predicate endp delimiter))
               (throw &#39;exit nil)))
         t)</span>))

(<a id='4210' tid='4209' class='u'>defun</a> <a id='4212' tid='4211' class='u'>paredit-move-past-close-and-reindent</a> <span class='i'>(close)</span>
  <span class='i'>(let ((open (paredit-missing-close)))
    (if open
        (if (eq close (matching-paren open))
            (save-excursion
              (message &quot;Missing closing delimiter: %c&quot; close)
              (insert close))
            (error &quot;Mismatched missing closing delimiter: %c ... %c&quot;
                   open close))))</span>
  <span class='i'>(up-list)</span>
  (<a id='1008' tid='1007' class='m'>if</a> (<a id='1010' tid='1009' class='m'>catch</a> <a id='1012' tid='1011' class='m'>&#39;</a><a id='1014' tid='1013' class='m'>return</a>                    <a id='1016' tid='1015' class='m'>; This CATCH returns T if it
</a>        (<a id='1018' tid='1017' class='m'>while</a> <a id='1020' tid='1019' class='m'>t</a>                        <a id='1022' tid='1021' class='m'>; should delete leading spaces
</a>          (<a id='1024' tid='1023' class='m'>save-excursion</a>               <a id='1026' tid='1025' class='m'>; and NIL if not.
</a>            (<a id='1028' tid='1027' class='m'>let</a> ((<a id='1030' tid='1029' class='m'>before-paren</a> (<a id='1032' tid='1031' class='m'>1-</a> (<a id='1034' tid='1033' class='m'>point</a>))))
              (<a id='1036' tid='1035' class='m'>back-to-indentation</a>)
              (<a id='1038' tid='1037' class='m'>cond</a> ((<a id='1040' tid='1039' class='m'>not</a> (<a id='1042' tid='1041' class='m'>eq</a> (<a id='1044' tid='1043' class='m'>point</a>) <a id='1046' tid='1045' class='m'>before-paren</a>))
                     <a id='1048' tid='1047' class='m'>;; Can&#39;t call PAREDIT-DELETE-LEADING-WHITESPACE
</a>                     <a id='1050' tid='1049' class='m'>;; here -- we must return from SAVE-EXCURSION
</a>                     <a id='1052' tid='1051' class='m'>;; first.
</a>                     (<a id='1054' tid='1053' class='m'>throw</a> <a id='1056' tid='1055' class='m'>&#39;</a><a id='1058' tid='1057' class='m'>return</a> <a id='1060' tid='1059' class='m'>t</a>))
                    ((<a id='1062' tid='1061' class='m'>save-excursion</a> (<a id='1064' tid='1063' class='m'>forward-line</a> <a id='1066' tid='1065' class='m'>-1</a>)
                                     (<a id='1068' tid='1067' class='m'>end-of-line</a>)
                                     (<a id='1070' tid='1069' class='m'>paredit-in-comment-p</a>))
                     <span class='i'>;; Moving the closing delimiter any further
</span>                     <a id='1072' tid='1071' class='m'>;; would put it into a comment, so we just
</a>                     <span class='i'>;; indent the closing delimiter where it is and
</span>                     <span class='i'>;; abort the loop, telling its continuation that
</span>                     <span class='i'>;; no leading whitespace should be deleted.
</span>                     (<a id='1074' tid='1073' class='m'>lisp-indent-line</a>)
                     (<a id='1076' tid='1075' class='m'>throw</a> <a id='1078' tid='1077' class='m'>&#39;</a><a id='1080' tid='1079' class='m'>return</a> <a id='1082' tid='1081' class='m'>nil</a>))
                    (<a id='1084' tid='1083' class='m'>t</a> (<a id='1086' tid='1085' class='m'>delete-indentation</a>)))))))
      (<a id='1088' tid='1087' class='m'>paredit-delete-leading-whitespace</a>)))

<span class='i'>(defun paredit-missing-close ()
  (save-excursion
    (paredit-handle-sexp-errors (backward-up-list)
      (error &quot;Not inside a list.&quot;))
    (let ((open (char-after)))
      (paredit-handle-sexp-errors (progn (forward-sexp) nil)
        open))))</span>

(<a id='2282' tid='2281' class='u'>defun</a> <a id='2284' tid='2283' class='u'>paredit-delete-leading-whitespace</a> ()
  <span class='i'>;; This assumes that we&#39;re on the closing delimiter already.
</span>  (<a id='2286' tid='2285' class='u'>save-excursion</a>
    (<a id='2288' tid='2287' class='u'>backward-char</a>)
    (<a id='2290' tid='2289' class='u'>while</a> (<a id='2292' tid='2291' class='u'>let</a> ((<a id='2294' tid='2293' class='u'>syn</a> (<a id='2296' tid='2295' class='u'>char-syntax</a> (<a id='2298' tid='2297' class='u'>char-before</a>))))
             (<a id='2300' tid='2299' class='u'>and</a> (<a id='2302' tid='2301' class='u'>or</a> (<a id='2304' tid='2303' class='u'>eq</a> <a id='2306' tid='2305' class='u'>syn</a> <a id='2308' tid='2307' class='u'>?\ </a>) (<a id='2310' tid='2309' class='u'>eq</a> <a id='2312' tid='2311' class='u'>syn</a> <a id='2314' tid='2313' class='u'>?-</a>))     <a id='2316' tid='2315' class='u'>; whitespace syntax
</a>                  <a id='2318' tid='2317' class='u'>;; The above line is a perfect example of why the
</a>                  <a id='2320' tid='2319' class='u'>;; following test is necessary.
</a>                  (<a id='2322' tid='2321' class='u'>not</a> (<a id='2324' tid='2323' class='u'>paredit-in-char-p</a> (<a id='2326' tid='2325' class='u'>1-</a> (<a id='2328' tid='2327' class='u'>point</a>))))))
      (<a id='2330' tid='2329' class='u'>backward-delete-char</a> <a id='2332' tid='2331' class='u'>1</a>))))

(<a id='2160' tid='2159' class='u'>defun</a> <a id='2162' tid='2161' class='u'>paredit-blink-paren-match</a> (<a id='2164' tid='2163' class='u'>another-line-p</a>)
  (<a id='2166' tid='2165' class='u'>if</a> (<a id='2168' tid='2167' class='u'>and</a> <a id='2170' tid='2169' class='u'>blink-matching-paren</a>
           (<a id='2172' tid='2171' class='u'>or</a> (<a id='2174' tid='2173' class='u'>not</a> <a id='2176' tid='2175' class='u'>show-paren-mode</a>) <a id='2178' tid='2177' class='u'>another-line-p</a>))
      (<a id='2180' tid='2179' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2182' tid='2181' class='u'>save-excursion</a>
          (<a id='2184' tid='2183' class='u'>backward-sexp</a>)
          (<a id='2186' tid='2185' class='u'>forward-sexp</a>)
          <a id='2188' tid='2187' class='u'>;; SHOW-PAREN-MODE inhibits any blinking, so we disable it
</a>          <a id='2190' tid='2189' class='u'>;; locally here.
</a>          (<a id='2192' tid='2191' class='u'>let</a> ((<a id='2194' tid='2193' class='u'>show-paren-mode</a> <a id='2196' tid='2195' class='u'>nil</a>))
            (<a id='2198' tid='2197' class='u'>blink-matching-open</a>))))))

(<a id='2334' tid='2333' class='u'>defun</a> <a id='2336' tid='2335' class='u'>paredit-doublequote</a> (<a id='2338' tid='2337' class='u'>&optional</a> <a id='2340' tid='2339' class='u'>n</a>)
  <a id='2342' tid='2341' class='u'>&quot;Insert a pair of double-quotes.
With a prefix argument N, wrap the following N S-expressions in
  double-quotes, escaping intermediate characters if necessary.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  pair of double-quotes around the region, again escaping intermediate
  characters if necessary.
Inside a comment, insert a literal double-quote.
At the end of a string, move past the closing double-quote.
In the middle of a string, insert a backslash-escaped double-quote.
If in a character literal, do nothing.  This prevents accidentally
  changing a what was in the character literal to become a meaningful
  delimiter unintentionally.&quot;</a>
  (<a id='2344' tid='2343' class='u'>interactive</a> <a id='2346' tid='2345' class='u'>&quot;P&quot;</a>)
  (<a id='2348' tid='2347' class='u'>cond</a> ((<a id='2350' tid='2349' class='u'>paredit-in-string-p</a>)
         (<a id='2352' tid='2351' class='u'>if</a> (<a id='2354' tid='2353' class='u'>eq</a> (<a id='2356' tid='2355' class='u'>cdr</a> (<a id='2358' tid='2357' class='u'>paredit-string-start+end-points</a>))
                 (<a id='2360' tid='2359' class='u'>point</a>))
             (<a id='2362' tid='2361' class='u'>forward-char</a>)             <a id='2364' tid='2363' class='u'>; We&#39;re on the closing quote.
</a>             (<a id='2366' tid='2365' class='u'>insert</a> <a id='2368' tid='2367' class='u'>?\\</a> <a id='2370' tid='2369' class='u'>?\&quot;</a> )))
        ((<a id='2372' tid='2371' class='u'>paredit-in-comment-p</a>)
         (<a id='2374' tid='2373' class='u'>insert</a> <a id='2376' tid='2375' class='u'>?\&quot;</a> ))
        ((<a id='2378' tid='2377' class='u'>not</a> (<a id='2380' tid='2379' class='u'>paredit-in-char-p</a>))
         (<a id='2382' tid='2381' class='u'>paredit-insert-pair</a> <a id='2384' tid='2383' class='u'>n</a> <a id='2386' tid='2385' class='u'>?\&quot;</a> <a id='2388' tid='2387' class='u'>?\&quot;</a> <a id='2390' tid='2389' class='u'>&#39;</a><a id='2392' tid='2391' class='u'>paredit-forward-for-quote</a>))))

(<a id='4064' tid='4063' class='u'>defun</a> <a id='4066' tid='4065' class='u'>paredit-meta-doublequote</a> (<a id='4068' tid='4067' class='u'>&optional</a> <a id='4070' tid='4069' class='u'>n</a>)
  <a id='4072' tid='4071' class='u'>&quot;Move to the end of the string, insert a newline, and indent.
If not in a string, act as `paredit-doublequote&#39;; if no prefix argument
  is specified and the region is not active or `transient-mark-mode&#39; is
  disabled, the default is to wrap one S-expression, however, not
  zero.&quot;</a>
  (<a id='4074' tid='4073' class='u'>interactive</a> <a id='4076' tid='4075' class='u'>&quot;P&quot;</a>)
  (<a id='4078' tid='4077' class='u'>if</a> (<a id='4080' tid='4079' class='u'>not</a> (<a id='4082' tid='4081' class='u'>paredit-in-string-p</a>))
      (<a id='4084' tid='4083' class='u'>paredit-doublequote</a> (<a id='4086' tid='4085' class='u'>or</a> <a id='4088' tid='4087' class='u'>n</a>
                               (<a id='4090' tid='4089' class='u'>and</a> (<a id='4092' tid='4091' class='u'>not</a> (<a id='4094' tid='4093' class='u'>paredit-region-active-p</a>))
                                    <a id='4096' tid='4095' class='u'>1</a>)))
    (<a id='4098' tid='4097' class='u'>let</a> ((<a id='4100' tid='4099' class='u'>start+end</a> (<a id='4102' tid='4101' class='u'>paredit-string-start+end-points</a>)))
      (<a id='4104' tid='4103' class='u'>goto-char</a> (<a id='4106' tid='4105' class='u'>1+</a> (<a id='4108' tid='4107' class='u'>cdr</a> <a id='4110' tid='4109' class='u'>start+end</a>)))
      (<a id='4112' tid='4111' class='u'>newline</a>)
      (<a id='4114' tid='4113' class='u'>lisp-indent-line</a>)
      (<a id='4116' tid='4115' class='u'>paredit-ignore-sexp-errors</a> (<a id='4118' tid='4117' class='u'>indent-sexp</a>)))))

(<a id='2616' tid='2615' class='u'>defun</a> <a id='2618' tid='2617' class='u'>paredit-forward-for-quote</a> (<a id='2620' tid='2619' class='u'>end</a>)
  (<a id='2622' tid='2621' class='u'>let</a> ((<a id='2624' tid='2623' class='u'>state</a> (<a id='2626' tid='2625' class='u'>paredit-current-parse-state</a>)))
    (<a id='2628' tid='2627' class='u'>while</a> (<a id='2630' tid='2629' class='u'>&lt;</a> (<a id='2632' tid='2631' class='u'>point</a>) <a id='2634' tid='2633' class='u'>end</a>)
      (<a id='2636' tid='2635' class='u'>let</a> ((<a id='2638' tid='2637' class='u'>new-state</a> (<a id='2640' tid='2639' class='u'>parse-partial-sexp</a> (<a id='2642' tid='2641' class='u'>point</a>) (<a id='2644' tid='2643' class='u'>1+</a> (<a id='2646' tid='2645' class='u'>point</a>))
                                           <a id='2648' tid='2647' class='u'>nil</a> <a id='2650' tid='2649' class='u'>nil</a> <a id='2652' tid='2651' class='u'>state</a>)))
        (<a id='2654' tid='2653' class='u'>if</a> (<a id='2656' tid='2655' class='u'>paredit-in-string-p</a> <a id='2658' tid='2657' class='u'>new-state</a>)
            (<a id='2660' tid='2659' class='u'>if</a> (<a id='2662' tid='2661' class='u'>not</a> (<a id='2664' tid='2663' class='u'>paredit-in-string-escape-p</a>))
                (<a id='2666' tid='2665' class='u'>setq</a> <a id='2668' tid='2667' class='u'>state</a> <a id='2670' tid='2669' class='u'>new-state</a>)
              <a id='2672' tid='2671' class='u'>;; Escape character: turn it into an escaped escape
</a>              <a id='2674' tid='2673' class='u'>;; character by appending another backslash.
</a>              (<a id='2676' tid='2675' class='u'>insert</a> <a id='2678' tid='2677' class='u'>?\\</a> )
              <a id='2680' tid='2679' class='u'>;; Now the point is after both escapes, and we want to
</a>              <a id='2682' tid='2681' class='u'>;; rescan from before the first one to after the second
</a>              <a id='2684' tid='2683' class='u'>;; one.
</a>              (<a id='2686' tid='2685' class='u'>setq</a> <a id='2688' tid='2687' class='u'>state</a>
                    (<a id='2690' tid='2689' class='u'>parse-partial-sexp</a> (<a id='2692' tid='2691' class='u'>-</a> (<a id='2694' tid='2693' class='u'>point</a>) <a id='2696' tid='2695' class='u'>2</a>) (<a id='2698' tid='2697' class='u'>point</a>)
                                        <a id='2700' tid='2699' class='u'>nil</a> <a id='2702' tid='2701' class='u'>nil</a> <a id='2704' tid='2703' class='u'>state</a>))
              <a id='2706' tid='2705' class='u'>;; Advance the end point, since we just inserted a new
</a>              <a id='2708' tid='2707' class='u'>;; character.
</a>              (<a id='2710' tid='2709' class='u'>setq</a> <a id='2712' tid='2711' class='u'>end</a> (<a id='2714' tid='2713' class='u'>1+</a> <a id='2716' tid='2715' class='u'>end</a>)))
          <a id='2718' tid='2717' class='u'>;; String: escape by inserting a backslash before the quote.
</a>          (<a id='2720' tid='2719' class='u'>backward-char</a>)
          (<a id='2722' tid='2721' class='u'>insert</a> <a id='2724' tid='2723' class='u'>?\\</a> )
          <a id='2726' tid='2725' class='u'>;; The point is now between the escape and the quote, and we
</a>          <a id='2728' tid='2727' class='u'>;; want to rescan from before the escape to after the quote.
</a>          (<a id='2730' tid='2729' class='u'>setq</a> <a id='2732' tid='2731' class='u'>state</a>
                (<a id='2734' tid='2733' class='u'>parse-partial-sexp</a> (<a id='2736' tid='2735' class='u'>1-</a> (<a id='2738' tid='2737' class='u'>point</a>)) (<a id='2740' tid='2739' class='u'>1+</a> (<a id='2742' tid='2741' class='u'>point</a>))
                                    <a id='2744' tid='2743' class='u'>nil</a> <a id='2746' tid='2745' class='u'>nil</a> <a id='2748' tid='2747' class='u'>state</a>))
          <a id='2750' tid='2749' class='u'>;; Advance the end point for the same reason as above.
</a>          (<a id='2752' tid='2751' class='u'>setq</a> <a id='2754' tid='2753' class='u'>end</a> (<a id='2756' tid='2755' class='u'>1+</a> <a id='2758' tid='2757' class='u'>end</a>)))))))

<span class='i'>;;;; Escape Insertion
</span>
(<a id='1734' tid='1733' class='u'>defun</a> <a id='1736' tid='1735' class='u'>paredit-backslash</a> ()
  <a id='1738' tid='1737' class='u'>&quot;Insert a backslash followed by a character to escape.&quot;</a>
  (<a id='1740' tid='1739' class='u'>interactive</a>)
  (<a id='1742' tid='1741' class='u'>insert</a> <a id='1744' tid='1743' class='u'>?\\</a> )
  <a id='1746' tid='1745' class='u'>;; This funny conditional is necessary because PAREDIT-IN-COMMENT-P
</a>  <a id='1748' tid='1747' class='u'>;; assumes that PAREDIT-IN-STRING-P already returned false; otherwise
</a>  <a id='1750' tid='1749' class='u'>;; it may give erroneous answers.
</a>  (<a id='1752' tid='1751' class='u'>if</a> (<a id='1754' tid='1753' class='u'>or</a> (<a id='1756' tid='1755' class='u'>paredit-in-string-p</a>)
          (<a id='1758' tid='1757' class='u'>not</a> (<a id='1760' tid='1759' class='u'>paredit-in-comment-p</a>)))
      (<a id='1762' tid='1761' class='u'>let</a> ((<a id='1764' tid='1763' class='u'>delp</a> <a id='1766' tid='1765' class='u'>t</a>))
        (<a id='1768' tid='1767' class='u'>unwind-protect</a> (<a id='1770' tid='1769' class='u'>setq</a> <a id='1772' tid='1771' class='u'>delp</a>
                              (<a id='1774' tid='1773' class='u'>call-interactively</a> <a id='1776' tid='1775' class='u'>&#39;</a><a id='1778' tid='1777' class='u'>paredit-escape</a>))
          <a id='1780' tid='1779' class='u'>;; We need this in an UNWIND-PROTECT so that the backlash is
</a>          <a id='1782' tid='1781' class='u'>;; left in there *only* if PAREDIT-ESCAPE return NIL normally
</a>          <a id='1784' tid='1783' class='u'>;; -- in any other case, such as the user hitting C-g or an
</a>          <a id='1786' tid='1785' class='u'>;; error occurring, we must delete the backslash to avoid
</a>          <a id='1788' tid='1787' class='u'>;; leaving a dangling escape.  (This control structure is a
</a>          <a id='1790' tid='1789' class='u'>;; crock.)
</a>          (<a id='1792' tid='1791' class='u'>if</a> <a id='1794' tid='1793' class='u'>delp</a> (<a id='1796' tid='1795' class='u'>backward-delete-char</a> <a id='1798' tid='1797' class='u'>1</a>))))))

<span class='i'>;;; This auxiliary interactive function returns true if the backslash
</span><span class='i'>;;; should be deleted and false if not.
</span>
(<a id='2394' tid='2393' class='u'>defun</a> <a id='2396' tid='2395' class='u'>paredit-escape</a> (<a id='2398' tid='2397' class='u'>char</a>)
  <a id='2400' tid='2399' class='u'>;; I&#39;m too lazy to figure out how to do this without a separate
</a>  <a id='2402' tid='2401' class='u'>;; interactive function.
</a>  (<a id='2404' tid='2403' class='u'>interactive</a> <a id='2406' tid='2405' class='u'>&quot;cEscaping character...&quot;</a>)
  (<a id='2408' tid='2407' class='u'>if</a> (<a id='2410' tid='2409' class='u'>eq</a> <a id='2412' tid='2411' class='u'>char</a> <a id='2414' tid='2413' class='u'>127</a>)                     <a id='2416' tid='2415' class='u'>; The backslash was a typo, so
</a>      <a id='2418' tid='2417' class='u'>t</a>                                 <a id='2420' tid='2419' class='u'>; the luser wants to delete it.
</a>    (<a id='2422' tid='2421' class='u'>insert</a> <a id='2424' tid='2423' class='u'>char</a>)                       <a id='2426' tid='2425' class='u'>; (Is there a better way to
</a>    <a id='2428' tid='2427' class='u'>nil</a>))                               <span class='i'>; express the rubout char?
</span>                                        <span class='i'>; ?\^? works, but ugh...)
</span>
(<a id='4214' tid='4213' class='u'>defun</a> <a id='4216' tid='4215' class='u'>paredit-newline</a> ()
  <span class='i'>&quot;Insert a newline and indent it.
This is like `newline-and-indent&#39;, but it not only indents the line
  that the point is on but also the S-expression following the point,
  if there is one.
Move forward one character first if on an escaped character.
If in a string, just insert a literal newline.
If in a comment and if followed by invalid structure, call
  `indent-new-comment-line&#39; to keep the invalid structure in a
  comment.&quot;</span>
  (<a id='4218' tid='4217' class='u'>interactive</a>)
  <span class='i'>(cond ((paredit-in-string-p)
         (newline))
        ((paredit-in-comment-p)
         (if (paredit-region-ok-p (point) (point-at-eol))
             (progn (newline-and-indent) (indent-sexp))
             (indent-new-comment-line)))
        (t
         (if (paredit-in-char-p)
             (forward-char))
         (newline-and-indent)
         ;; Indent the following S-expression, but don&#39;t signal an
         ;; error if there&#39;s only a closing delimiter after the point.
         (paredit-ignore-sexp-errors (indent-sexp))))</span>)

<span class='i'>(defun paredit-reindent-defun (&optional argument)
  &quot;Reindent the definition that the point is on.
If the point is in a string or a comment, fill the paragraph instead,
  and with a prefix argument, justify as well.&quot;
  (interactive &quot;P&quot;)
  (if (or (paredit-in-string-p)
          (paredit-in-comment-p))
      (fill-paragraph argument)
    (save-excursion
      (end-of-defun)
      (beginning-of-defun)
      (indent-sexp))))</span>

<span class='i'>;;;; Comment Insertion
</span>
(<a id='4438' tid='4437' class='u'>defun</a> <a id='4440' tid='4439' class='u'>paredit-semicolon</a> (<a id='4442' tid='4441' class='u'>&optional</a> <a id='4444' tid='4443' class='u'>n</a>)
  <span class='i'>&quot;Insert a semicolon.
With a prefix argument N, insert N semicolons.
If in a string, do just that and nothing else.
If in a character literal, move to the beginning of the character
  literal before inserting the semicolon.
If the enclosing list ends on the line after the point, break the line
  after the last S-expression following the point.
If a list begins on the line after the point but ends on a different
  line, break the line after the last S-expression following the point
  before the list.&quot;</span>
  <span class='i'>(interactive &quot;p&quot;)</span>
  <span class='i'>(if (or (paredit-in-string-p) (paredit-in-comment-p))
      (insert (make-string (or n 1) ?\; ))
    (if (paredit-in-char-p)
        (backward-char 2))
    (let ((line-break-point (paredit-semicolon-find-line-break-point)))
      (if line-break-point
          (paredit-semicolon-with-line-break line-break-point (or n 1))
          (insert (make-string (or n 1) ?\; )))))</span>)

<span class='i'>(defun paredit-semicolon-find-line-break-point ()
  (let ((line-break-point nil)
        (eol (point-at-eol)))
    (and (save-excursion
           (paredit-handle-sexp-errors
               (progn
                 (while
                     (progn
                       (setq line-break-point (point))
                       (forward-sexp)
                       (and (eq eol (point-at-eol))
                            (not (eobp)))))
                 (backward-sexp)
                 (eq eol (point-at-eol)))
             ;; If we hit the end of an expression, but the closing
             ;; delimiter is on another line, don&#39;t break the line.
             (save-excursion
               (paredit-skip-whitespace t (point-at-eol))
               (not (or (eolp) (eq (char-after) ?\; ))))))
         line-break-point)))</span>

<span class='i'>(defun paredit-semicolon-with-line-break (line-break-point n)
  (let ((line-break-marker (make-marker)))
    (set-marker line-break-marker line-break-point)
    (set-marker-insertion-type line-break-marker t)
    (insert (make-string (or n 1) ?\; ))
    (save-excursion
      (goto-char line-break-marker)
      (set-marker line-break-marker nil)
      (newline)
      (lisp-indent-line)
      ;; This step is redundant if we are inside a list, but even if we
      ;; are at the top level, we want at least to indent whatever we
      ;; bumped off the line.
      (paredit-ignore-sexp-errors (indent-sexp))
      (paredit-indent-sexps))))</span>

<span class='i'>;;; This is all a horrible, horrible hack, primarily for GNU Emacs 21,
</span><span class='i'>;;; in which there is no `comment-or-uncomment-region&#39;.
</span>
<span class='i'>(autoload &#39;comment-forward &quot;newcomment&quot;)</span>
<span class='i'>(autoload &#39;comment-normalize-vars &quot;newcomment&quot;)</span>
<span class='i'>(autoload &#39;comment-region &quot;newcomment&quot;)</span>
<span class='i'>(autoload &#39;comment-search-forward &quot;newcomment&quot;)</span>
<span class='i'>(autoload &#39;uncomment-region &quot;newcomment&quot;)</span>

<span class='i'>(defun paredit-initialize-comment-dwim ()
  (require &#39;newcomment)
  (if (not (fboundp &#39;comment-or-uncomment-region))
      (defalias &#39;comment-or-uncomment-region
        (lambda (beginning end &optional argument)
          (interactive &quot;*r\nP&quot;)
          (if (save-excursion (goto-char beginning)
                              (comment-forward (point-max))
                              (&lt;= end (point)))
              (uncomment-region beginning end argument)
              (comment-region beginning end argument)))))
  (defalias &#39;paredit-initialize-comment-dwim &#39;comment-normalize-vars)
  (comment-normalize-vars))</span>

(<a id='2208' tid='2207' class='u'>defun</a> <a id='2210' tid='2209' class='u'>paredit-comment-dwim</a> <span class='i'>(&optional argument)</span>
  <a id='2212' tid='2211' class='u'>&quot;Call the Lisp comment command you want (Do What I Mean).
This is like `comment-dwim&#39;, but it is specialized for Lisp editing.
If transient mark mode is enabled and the mark is active, comment or
  uncomment the selected region, depending on whether it was entirely
  commented not not already.
If there is already a comment on the current line, with no prefix
  argument, indent to that comment; with a prefix argument, kill that
  comment.
Otherwise, insert a comment appropriate for the context and ensure that
  any code following the comment is moved to the next line.
At the top level, where indentation is calculated to be at column 0,
  insert a triple-semicolon comment; within code, where the indentation
  is calculated to be non-zero, and on the line there is either no code
  at all or code after the point, insert a double-semicolon comment;
  and if the point is after all code on the line, insert a single-
  semicolon margin comment at `comment-column&#39;.&quot;</a>
  (<a id='2214' tid='2213' class='u'>interactive</a> <a id='2216' tid='2215' class='u'>&quot;*P&quot;</a>)
  <span class='i'>(paredit-initialize-comment-dwim)</span>
  <span class='i'>(cond ((paredit-region-active-p)
         (comment-or-uncomment-region (region-beginning)
                                      (region-end)
                                      argument))
        ((paredit-comment-on-line-p)
         (if argument
             (comment-kill (if (integerp argument) argument nil))
             (comment-indent)))
        (t (paredit-insert-comment)))</span>)

(<a id='2218' tid='2217' class='u'>defun</a> <a id='2220' tid='2219' class='u'>paredit-comment-on-line-p</a> ()
  <span class='i'>&quot;True if there is a comment on the line following point.
This is expected to be called only in `paredit-comment-dwim&#39;; do not
  call it elsewhere.&quot;</span>
  (<a id='1090' tid='1089' class='m'>save-excursion</a>
    (<a id='1092' tid='1091' class='m'>beginning-of-line</a>)
    (<a id='1094' tid='1093' class='m'>let</a> ((<a id='1096' tid='1095' class='m'>comment-p</a> <a id='1098' tid='1097' class='m'>nil</a>))
      <a id='1100' tid='1099' class='m'>;; Search forward for a comment beginning.  If there is one, set
</a>      <a id='1102' tid='1101' class='m'>;; COMMENT-P to true; if not, it will be nil.
</a>      (<a id='1104' tid='1103' class='m'>while</a> (<span class='i'>progn</span>
               <span class='i'>(setq comment-p          ;t -&gt; no error
                     (comment-search-forward (point-at-eol) t))</span>
               (<a id='1106' tid='1105' class='m'>and</a> <a id='1108' tid='1107' class='m'>comment-p</a>
                    (<a id='1110' tid='1109' class='m'>or</a> (<a id='1112' tid='1111' class='m'>paredit-in-string-p</a>)
                        (<a id='1114' tid='1113' class='m'>paredit-in-char-p</a> (<a id='1116' tid='1115' class='m'>1-</a> (<a id='1118' tid='1117' class='m'>point</a>))))))
        (<a id='1120' tid='1119' class='m'>forward-char</a>))
      <a id='1122' tid='1121' class='m'>comment-p</a>)))

(<a id='3322' tid='3321' class='u'>defun</a> <a id='3324' tid='3323' class='u'>paredit-insert-comment</a> ()
  (<a id='1124' tid='1123' class='m'>let</a> ((<a id='1126' tid='1125' class='m'>code-after-p</a>
         (<a id='1128' tid='1127' class='m'>save-excursion</a> (<a id='1130' tid='1129' class='m'>paredit-skip-whitespace</a> <a id='1132' tid='1131' class='m'>t</a> (<a id='1134' tid='1133' class='m'>point-at-eol</a>))
                         (<a id='1136' tid='1135' class='m'>not</a> (<a id='1138' tid='1137' class='m'>eolp</a>))))
        (<a id='1140' tid='1139' class='m'>code-before-p</a>
         (<a id='1142' tid='1141' class='m'>save-excursion</a> (<a id='1144' tid='1143' class='m'>paredit-skip-whitespace</a> <a id='1146' tid='1145' class='m'>nil</a> (<a id='1148' tid='1147' class='m'>point-at-bol</a>))
                         (<a id='1150' tid='1149' class='m'>not</a> (<a id='1152' tid='1151' class='m'>bolp</a>)))))
    (<span class='i'>cond</span> ((<a id='1154' tid='1153' class='m'>and</a> (<a id='1156' tid='1155' class='m'>bolp</a>)
                (<span class='i'>let</span> ((<span class='i'>indent</span>
                       (<a id='1158' tid='1157' class='m'>let</a> ((<a id='1160' tid='1159' class='m'>indent</a> (<a id='1162' tid='1161' class='m'>calculate-lisp-indent</a>)))
                         (<a id='1164' tid='1163' class='m'>if</a> (<a id='1166' tid='1165' class='m'>consp</a> <a id='1168' tid='1167' class='m'>indent</a>) (<a id='1170' tid='1169' class='m'>car</a> <a id='1172' tid='1171' class='m'>indent</a>) <a id='1174' tid='1173' class='m'>indent</a>))))
                  <span class='i'>(and indent (zerop indent))</span>))
           <span class='i'>;; Top-level comment
</span>           <span class='i'>(if code-after-p (save-excursion (newline)))</span>
           <span class='i'>(insert &quot;;;; &quot;)</span>)
          <span class='i'>((or code-after-p (not code-before-p))
           ;; Code comment
           (if code-before-p (newline))
           (lisp-indent-line)
           (insert &quot;;; &quot;)
           (if code-after-p
               (save-excursion
                 (newline)
                 (lisp-indent-line)
                 (paredit-indent-sexps))))</span>
          <span class='i'>(t
           ;; Margin comment
           (indent-to comment-column 1) ; 1 -&gt; force one leading space
           (insert ?\; ))</span>)))

<span class='i'>;;;; Character Deletion
</span>
(<a id='2504' tid='2503' class='u'>defun</a> <a id='2506' tid='2505' class='u'>paredit-forward-delete</a> <span class='i'>(&optional argument)</span>
  <span class='i'>&quot;Delete a character forward or move forward over a delimiter.
If on an opening S-expression delimiter, move forward into the
  S-expression.
If on a closing S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters forward.
With a `C-u&#39; prefix argument, simply delete a character forward,
  without regard for delimiter balancing.&quot;</span>
  (<a id='2508' tid='2507' class='u'>interactive</a> <a id='2510' tid='2509' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> <span class='i'>((or (consp argument) (eobp))
         (delete-char 1))</span>
        <span class='i'>((integerp argument)
         (if (&lt; argument 0)
             (paredit-backward-delete argument)
             (while (&gt; argument 0)
               (paredit-forward-delete)
               (setq argument (- argument 1)))))</span>
        <span class='i'>((paredit-in-string-p)
         (paredit-forward-delete-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         ;++ What to do here?  This could move a partial S-expression
         ;++ into a comment and thereby invalidate the file&#39;s form,
         ;++ or move random text out of a comment.
         (delete-char 1))</span>
        ((<a id='1176' tid='1175' class='m'>paredit-in-char-p</a>)            <a id='1178' tid='1177' class='m'>; Escape -- delete both chars.
</a>         (<a id='1180' tid='1179' class='m'>backward-delete-char</a> <a id='1182' tid='1181' class='m'>1</a>)
         (<a id='1184' tid='1183' class='m'>delete-char</a> <a id='1186' tid='1185' class='m'>1</a>))
        ((<a id='552' tid='551' class='m'>eq</a> (<a id='554' tid='553' class='m'>char-after</a>) <a id='556' tid='555' class='m'>?\\</a> )         <a id='558' tid='557' class='m'>; ditto
</a>         (<a id='560' tid='559' class='m'>delete-char</a> <a id='562' tid='561' class='m'>2</a>))
        ((<a id='452' tid='451' class='m'>let</a> ((<a id='454' tid='453' class='m'>syn</a> (<a id='456' tid='455' class='m'>char-syntax</a> (<a id='458' tid='457' class='m'>char-after</a>))))
           (<a id='460' tid='459' class='m'>or</a> (<a id='462' tid='461' class='m'>eq</a> <a id='464' tid='463' class='m'>syn</a> <a id='466' tid='465' class='m'>?\(</a> )
               (<a id='468' tid='467' class='m'>eq</a> <a id='470' tid='469' class='m'>syn</a> <a id='472' tid='471' class='m'>?\&quot;</a> )))
         <span class='i'>(if (save-excursion
               (paredit-handle-sexp-errors (progn (forward-sexp) t)
                 nil))
             (forward-char)
           (message &quot;Deleting spurious opening delimiter.&quot;)
           (delete-char 1))</span>)
        ((<a id='330' tid='329' class='m'>and</a> (<a id='332' tid='331' class='m'>not</a> (<a id='334' tid='333' class='m'>paredit-in-char-p</a> (<a id='336' tid='335' class='m'>1-</a> (<a id='338' tid='337' class='m'>point</a>))))
              (<a id='340' tid='339' class='m'>eq</a> (<a id='342' tid='341' class='m'>char-syntax</a> (<a id='344' tid='343' class='m'>char-after</a>)) <a id='346' tid='345' class='m'>?\)</a> )
              (<a id='348' tid='347' class='m'>eq</a> (<a id='350' tid='349' class='m'>char-before</a>) (<a id='352' tid='351' class='m'>matching-paren</a> (<a id='354' tid='353' class='m'>char-after</a>))))
         (<a id='356' tid='355' class='m'>backward-delete-char</a> <a id='358' tid='357' class='m'>1</a>)       <a id='360' tid='359' class='m'>; Empty list -- delete both
</a>         (<a id='362' tid='361' class='m'>delete-char</a> <a id='364' tid='363' class='m'>1</a>))               <span class='i'>;   delimiters.
</span>        <span class='i'>;; Just delete a single character, if it&#39;s not a closing
</span>        <span class='i'>;; delimiter.  (The character literal case is already handled
</span>        <span class='i'>;; by now.)
</span>        ((<a id='278' tid='277' class='m'>not</a> (<a id='280' tid='279' class='m'>eq</a> (<a id='282' tid='281' class='m'>char-syntax</a> (<a id='284' tid='283' class='m'>char-after</a>)) <a id='286' tid='285' class='m'>?\)</a> ))
         (<a id='288' tid='287' class='m'>delete-char</a> <a id='290' tid='289' class='m'>1</a>))))

(<a id='2512' tid='2511' class='u'>defun</a> <a id='2514' tid='2513' class='u'>paredit-forward-delete-in-string</a> ()
  (<a id='2516' tid='2515' class='u'>let</a> ((<a id='2518' tid='2517' class='u'>start+end</a> (<a id='2520' tid='2519' class='u'>paredit-string-start+end-points</a>)))
    (<a id='2522' tid='2521' class='u'>cond</a> ((<a id='2524' tid='2523' class='u'>not</a> (<a id='2526' tid='2525' class='u'>eq</a> (<a id='2528' tid='2527' class='u'>point</a>) (<a id='2530' tid='2529' class='u'>cdr</a> <a id='2532' tid='2531' class='u'>start+end</a>)))
           <a id='2534' tid='2533' class='u'>;; If it&#39;s not the close-quote, it&#39;s safe to delete.  But
</a>           <a id='2536' tid='2535' class='u'>;; first handle the case that we&#39;re in a string escape.
</a>           (<a id='2538' tid='2537' class='u'>cond</a> ((<a id='2540' tid='2539' class='u'>paredit-in-string-escape-p</a>)
                  <a id='2542' tid='2541' class='u'>;; We&#39;re right after the backslash, so backward
</a>                  <a id='2544' tid='2543' class='u'>;; delete it before deleting the escaped character.
</a>                  (<a id='2546' tid='2545' class='u'>backward-delete-char</a> <a id='2548' tid='2547' class='u'>1</a>))
                 ((<a id='2550' tid='2549' class='u'>eq</a> (<a id='2552' tid='2551' class='u'>char-after</a>) <a id='2554' tid='2553' class='u'>?\\</a> )
                  <a id='2556' tid='2555' class='u'>;; If we&#39;re not in a string escape, but we are on a
</a>                  <a id='2558' tid='2557' class='u'>;; backslash, it must start the escape for the next
</a>                  <a id='2560' tid='2559' class='u'>;; character, so delete the backslash before deleting
</a>                  <a id='2562' tid='2561' class='u'>;; the next character.
</a>                  (<a id='2564' tid='2563' class='u'>delete-char</a> <a id='2566' tid='2565' class='u'>1</a>)))
           (<a id='2568' tid='2567' class='u'>delete-char</a> <a id='2570' tid='2569' class='u'>1</a>))
          ((<a id='2572' tid='2571' class='u'>eq</a> (<a id='2574' tid='2573' class='u'>1-</a> (<a id='2576' tid='2575' class='u'>point</a>)) (<a id='2578' tid='2577' class='u'>car</a> <a id='2580' tid='2579' class='u'>start+end</a>))
           <a id='2582' tid='2581' class='u'>;; If it is the close-quote, delete only if we&#39;re also right
</a>           <a id='2584' tid='2583' class='u'>;; past the open-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='2586' tid='2585' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='2588' tid='2587' class='u'>backward-delete-char</a> <a id='2590' tid='2589' class='u'>1</a>)
           (<a id='2592' tid='2591' class='u'>delete-char</a> <a id='2594' tid='2593' class='u'>1</a>)))))

(<a id='1868' tid='1867' class='u'>defun</a> <a id='1870' tid='1869' class='u'>paredit-backward-delete</a> <span class='i'>(&optional argument)</span>
  <span class='i'>&quot;Delete a character backward or move backward over a delimiter.
If on a closing S-expression delimiter, move backward into the
  S-expression.
If on an opening S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters backward.
With a `C-u&#39; prefix argument, simply delete a character backward,
  without regard for delimiter balancing.&quot;</span>
  (<a id='1872' tid='1871' class='u'>interactive</a> <a id='1874' tid='1873' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> <span class='i'>((or (consp argument) (bobp))
         ;++ Should this untabify?
         (backward-delete-char 1))</span>
        <span class='i'>((integerp argument)
         (if (&lt; argument 0)
             (paredit-forward-delete (- 0 argument))
             (while (&gt; argument 0)
               (paredit-backward-delete)
               (setq argument (- argument 1)))))</span>
        <span class='i'>((paredit-in-string-p)
         (paredit-backward-delete-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         (backward-delete-char 1))</span>
        ((<a id='1188' tid='1187' class='m'>paredit-in-char-p</a>)            <a id='1190' tid='1189' class='m'>; Escape -- delete both chars.
</a>         (<a id='1192' tid='1191' class='m'>backward-delete-char</a> <a id='1194' tid='1193' class='m'>1</a>)
         (<a id='1196' tid='1195' class='m'>delete-char</a> <a id='1198' tid='1197' class='m'>1</a>))
        ((<a id='564' tid='563' class='m'>paredit-in-char-p</a> (<a id='566' tid='565' class='m'>1-</a> (<a id='568' tid='567' class='m'>point</a>)))
         (<a id='570' tid='569' class='m'>backward-delete-char</a> <a id='572' tid='571' class='m'>2</a>))      <span class='i'>; ditto
</span>        ((<a id='474' tid='473' class='m'>let</a> ((<a id='476' tid='475' class='m'>syn</a> (<a id='478' tid='477' class='m'>char-syntax</a> (<a id='480' tid='479' class='m'>char-before</a>))))
           (<a id='482' tid='481' class='m'>or</a> (<a id='484' tid='483' class='m'>eq</a> <a id='486' tid='485' class='m'>syn</a> <a id='488' tid='487' class='m'>?\)</a> )
               (<a id='490' tid='489' class='m'>eq</a> <a id='492' tid='491' class='m'>syn</a> <a id='494' tid='493' class='m'>?\&quot;</a> )))
         <span class='i'>(if (save-excursion
               (paredit-handle-sexp-errors (progn (backward-sexp) t)
                 nil))
             (backward-char)
           (message &quot;Deleting spurious closing delimiter.&quot;)
           (backward-delete-char 1))</span>)
        ((<a id='366' tid='365' class='m'>and</a> (<a id='368' tid='367' class='m'>eq</a> (<a id='370' tid='369' class='m'>char-syntax</a> (<a id='372' tid='371' class='m'>char-before</a>)) <a id='374' tid='373' class='m'>?\(</a> )
              (<a id='376' tid='375' class='m'>eq</a> (<a id='378' tid='377' class='m'>char-after</a>) (<a id='380' tid='379' class='m'>matching-paren</a> (<a id='382' tid='381' class='m'>char-before</a>))))
         (<a id='384' tid='383' class='m'>backward-delete-char</a> <a id='386' tid='385' class='m'>1</a>)       <a id='388' tid='387' class='m'>; Empty list -- delete both
</a>         (<a id='390' tid='389' class='m'>delete-char</a> <a id='392' tid='391' class='m'>1</a>))               <span class='i'>;   delimiters.
</span>        <span class='i'>;; Delete it, unless it&#39;s an opening delimiter.  The case of
</span>        <span class='i'>;; character literals is already handled by now.
</span>        ((<a id='292' tid='291' class='m'>not</a> (<a id='294' tid='293' class='m'>eq</a> (<a id='296' tid='295' class='m'>char-syntax</a> (<a id='298' tid='297' class='m'>char-before</a>)) <a id='300' tid='299' class='m'>?\(</a> ))
         (<a id='302' tid='301' class='m'>backward-delete-char-untabify</a> <a id='304' tid='303' class='m'>1</a>))))

(<a id='1876' tid='1875' class='u'>defun</a> <a id='1878' tid='1877' class='u'>paredit-backward-delete-in-string</a> ()
  (<a id='1880' tid='1879' class='u'>let</a> ((<a id='1882' tid='1881' class='u'>start+end</a> (<a id='1884' tid='1883' class='u'>paredit-string-start+end-points</a>)))
    (<a id='1886' tid='1885' class='u'>cond</a> ((<a id='1888' tid='1887' class='u'>not</a> (<a id='1890' tid='1889' class='u'>eq</a> (<a id='1892' tid='1891' class='u'>1-</a> (<a id='1894' tid='1893' class='u'>point</a>)) (<a id='1896' tid='1895' class='u'>car</a> <a id='1898' tid='1897' class='u'>start+end</a>)))
           <a id='1900' tid='1899' class='u'>;; If it&#39;s not the open-quote, it&#39;s safe to delete.
</a>           (<a id='1902' tid='1901' class='u'>if</a> (<a id='1904' tid='1903' class='u'>paredit-in-string-escape-p</a>)
               <a id='1906' tid='1905' class='u'>;; If we&#39;re on a string escape, since we&#39;re about to
</a>               <a id='1908' tid='1907' class='u'>;; delete the backslash, we must first delete the
</a>               <a id='1910' tid='1909' class='u'>;; escaped char.
</a>               (<a id='1912' tid='1911' class='u'>delete-char</a> <a id='1914' tid='1913' class='u'>1</a>))
           (<a id='1916' tid='1915' class='u'>backward-delete-char</a> <a id='1918' tid='1917' class='u'>1</a>)
           (<a id='1920' tid='1919' class='u'>if</a> (<a id='1922' tid='1921' class='u'>paredit-in-string-escape-p</a>)
               <a id='1924' tid='1923' class='u'>;; If, after deleting a character, we find ourselves in
</a>               <a id='1926' tid='1925' class='u'>;; a string escape, we must have deleted the escaped
</a>               <a id='1928' tid='1927' class='u'>;; character, and the backslash is behind the point, so
</a>               <a id='1930' tid='1929' class='u'>;; backward delete it.
</a>               (<a id='1932' tid='1931' class='u'>backward-delete-char</a> <a id='1934' tid='1933' class='u'>1</a>)))
          ((<a id='1936' tid='1935' class='u'>eq</a> (<a id='1938' tid='1937' class='u'>point</a>) (<a id='1940' tid='1939' class='u'>cdr</a> <a id='1942' tid='1941' class='u'>start+end</a>))
           <a id='1944' tid='1943' class='u'>;; If it is the open-quote, delete only if we&#39;re also right
</a>           <a id='1946' tid='1945' class='u'>;; past the close-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='1948' tid='1947' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='1950' tid='1949' class='u'>backward-delete-char</a> <a id='1952' tid='1951' class='u'>1</a>)
           (<a id='1954' tid='1953' class='u'>delete-char</a> <a id='1956' tid='1955' class='u'>1</a>)))))

<span class='i'>;;;; Killing
</span>
(<a id='3658' tid='3657' class='u'>defun</a> <a id='3660' tid='3659' class='u'>paredit-kill</a> <span class='i'>(&optional argument)</span>
  <span class='i'>&quot;Kill a line as if with `kill-line&#39;, but respecting delimiters.
In a string, act exactly as `kill-line&#39; but do not kill past the
  closing string delimiter.
On a line with no S-expressions on it starting after the point or
  within a comment, act exactly as `kill-line&#39;.
Otherwise, kill all S-expressions that start after the point.
With a `C-u&#39; prefix argument, just do the standard `kill-line&#39;.
With a numeric prefix argument N, do `kill-line&#39; that many times.&quot;</span>
  (<a id='3662' tid='3661' class='u'>interactive</a> <a id='3664' tid='3663' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> <span class='i'>(argument
         (kill-line (if (integerp argument) argument 1)))</span>
        <span class='i'>((paredit-in-string-p)
         (paredit-kill-line-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         (kill-line))</span>
        ((<a id='244' tid='243' class='m'>save-excursion</a> (<a id='246' tid='245' class='m'>paredit-skip-whitespace</a> <a id='248' tid='247' class='m'>t</a> (<a id='250' tid='249' class='m'>point-at-eol</a>))
                         (<a id='252' tid='251' class='m'>or</a> (<a id='254' tid='253' class='m'>eolp</a>) (<a id='256' tid='255' class='m'>eq</a> (<a id='258' tid='257' class='m'>char-after</a>) <a id='260' tid='259' class='m'>?\;</a> )))
         <span class='i'>;** Be careful about trailing backslashes.
</span>         <span class='i'>(if (paredit-in-char-p)
             (backward-char))</span>
         <span class='i'>(kill-line)</span>)
        <span class='i'>(t (paredit-kill-sexps-on-line))</span>))

(<a id='3666' tid='3665' class='u'>defun</a> <a id='3668' tid='3667' class='u'>paredit-kill-line-in-string</a> ()
  (<span class='i'>if</span> (<a id='1200' tid='1199' class='m'>save-excursion</a> (<a id='1202' tid='1201' class='m'>paredit-skip-whitespace</a> <a id='1204' tid='1203' class='m'>t</a> (<a id='1206' tid='1205' class='m'>point-at-eol</a>))
                      (<a id='1208' tid='1207' class='m'>eolp</a>))
      <span class='i'>(kill-line)</span>
    <span class='i'>(save-excursion
      ;; Be careful not to split an escape sequence.
      (if (paredit-in-string-escape-p)
          (backward-char))
      (kill-region (point)
                   (min (point-at-eol)
                        (cdr (paredit-string-start+end-points)))))</span>))

(<a id='3670' tid='3669' class='u'>defun</a> <a id='3672' tid='3671' class='u'>paredit-kill-sexps-on-line</a> ()
  (<a id='3674' tid='3673' class='u'>if</a> (<a id='3676' tid='3675' class='u'>paredit-in-char-p</a>)               <a id='3678' tid='3677' class='u'>; Move past the \ and prefix.
</a>      (<a id='3680' tid='3679' class='u'>backward-char</a> <a id='3682' tid='3681' class='u'>2</a>))                <a id='3684' tid='3683' class='u'>; (# in Scheme/CL, ? in elisp)
</a>  (<a id='3686' tid='3685' class='u'>let</a> ((<a id='3688' tid='3687' class='u'>beginning</a> (<a id='3690' tid='3689' class='u'>point</a>))
        (<a id='3692' tid='3691' class='u'>eol</a> (<a id='3694' tid='3693' class='u'>point-at-eol</a>)))
    (<a id='3696' tid='3695' class='u'>let</a> ((<a id='3698' tid='3697' class='u'>end-of-list-p</a> (<a id='3700' tid='3699' class='u'>paredit-forward-sexps-to-kill</a> <a id='3702' tid='3701' class='u'>beginning</a> <a id='3704' tid='3703' class='u'>eol</a>)))
      <a id='3706' tid='3705' class='u'>;; If we got to the end of the list and it&#39;s on the same line,
</a>      <a id='3708' tid='3707' class='u'>;; move backward past the closing delimiter before killing.  (This
</a>      <a id='3710' tid='3709' class='u'>;; allows something like killing the whitespace in (    ).)
</a>      (<a id='3712' tid='3711' class='u'>if</a> <a id='3714' tid='3713' class='u'>end-of-list-p</a> (<a id='3716' tid='3715' class='u'>progn</a> (<a id='3718' tid='3717' class='u'>up-list</a>) (<a id='3720' tid='3719' class='u'>backward-char</a>)))
      (<a id='3722' tid='3721' class='u'>if</a> <a id='3724' tid='3723' class='u'>kill-whole-line</a>
          (<a id='3726' tid='3725' class='u'>paredit-kill-sexps-on-whole-line</a> <a id='3728' tid='3727' class='u'>beginning</a>)
        (<a id='3730' tid='3729' class='u'>kill-region</a> <a id='3732' tid='3731' class='u'>beginning</a>
                     <a id='3734' tid='3733' class='u'>;; If all of the S-expressions were on one line,
</a>                     <a id='3736' tid='3735' class='u'>;; i.e. we&#39;re still on that line after moving past
</a>                     <a id='3738' tid='3737' class='u'>;; the last one, kill the whole line, including
</a>                     <a id='3740' tid='3739' class='u'>;; any comments; otherwise just kill to the end of
</a>                     <a id='3742' tid='3741' class='u'>;; the last S-expression we found.  Be sure,
</a>                     <a id='3744' tid='3743' class='u'>;; though, not to kill any closing parentheses.
</a>                     (<a id='3746' tid='3745' class='u'>if</a> (<a id='3748' tid='3747' class='u'>and</a> (<a id='3750' tid='3749' class='u'>not</a> <a id='3752' tid='3751' class='u'>end-of-list-p</a>)
                              (<a id='3754' tid='3753' class='u'>eq</a> (<a id='3756' tid='3755' class='u'>point-at-eol</a>) <a id='3758' tid='3757' class='u'>eol</a>))
                         <a id='3760' tid='3759' class='u'>eol</a>
                         (<a id='3762' tid='3761' class='u'>point</a>)))))))

<span class='i'>;;; Please do not try to understand this code unless you have a VERY
</span><span class='i'>;;; good reason to do so.  I gave up trying to figure it out well
</span><span class='i'>;;; enough to explain it, long ago.
</span>
(<a id='2890' tid='2889' class='u'>defun</a> <a id='2892' tid='2891' class='u'>paredit-forward-sexps-to-kill</a> (<a id='2894' tid='2893' class='u'>beginning</a> <a id='2896' tid='2895' class='u'>eol</a>)
  (<a id='2898' tid='2897' class='u'>let</a> ((<a id='2900' tid='2899' class='u'>end-of-list-p</a> <a id='2902' tid='2901' class='u'>nil</a>)
        (<a id='2904' tid='2903' class='u'>firstp</a> <a id='2906' tid='2905' class='u'>t</a>))
    <a id='2908' tid='2907' class='u'>;; Move to the end of the last S-expression that started on this
</a>    <a id='2910' tid='2909' class='u'>;; line, or to the closing delimiter if the last S-expression in
</a>    <a id='2912' tid='2911' class='u'>;; this list is on the line.
</a>    (<a id='2914' tid='2913' class='u'>catch</a> <a id='2916' tid='2915' class='u'>&#39;</a><a id='2918' tid='2917' class='u'>return</a>
      (<a id='2920' tid='2919' class='u'>while</a> <a id='2922' tid='2921' class='u'>t</a>
        <a id='2924' tid='2923' class='u'>;; This and the `kill-whole-line&#39; business below fix a bug that
</a>        <a id='2926' tid='2925' class='u'>;; inhibited any S-expression at the very end of the buffer
</a>        <a id='2928' tid='2927' class='u'>;; (with no trailing newline) from being deleted.  It&#39;s a
</a>        <a id='2930' tid='2929' class='u'>;; bizarre fix that I ought to document at some point, but I am
</a>        <a id='2932' tid='2931' class='u'>;; too busy at the moment to do so.
</a>        (<a id='2934' tid='2933' class='u'>if</a> (<a id='2936' tid='2935' class='u'>and</a> <a id='2938' tid='2937' class='u'>kill-whole-line</a> (<a id='2940' tid='2939' class='u'>eobp</a>)) (<a id='2942' tid='2941' class='u'>throw</a> <a id='2944' tid='2943' class='u'>&#39;</a><a id='2946' tid='2945' class='u'>return</a> <a id='2948' tid='2947' class='u'>nil</a>))
        (<a id='2950' tid='2949' class='u'>save-excursion</a>
          (<a id='2952' tid='2951' class='u'>paredit-handle-sexp-errors</a> (<a id='2954' tid='2953' class='u'>forward-sexp</a>)
            (<a id='2956' tid='2955' class='u'>up-list</a>)
            (<a id='2958' tid='2957' class='u'>setq</a> <a id='2960' tid='2959' class='u'>end-of-list-p</a> (<a id='2962' tid='2961' class='u'>eq</a> (<a id='2964' tid='2963' class='u'>point-at-eol</a>) <a id='2966' tid='2965' class='u'>eol</a>))
            (<a id='2968' tid='2967' class='u'>throw</a> <a id='2970' tid='2969' class='u'>&#39;</a><a id='2972' tid='2971' class='u'>return</a> <a id='2974' tid='2973' class='u'>nil</a>))
          (<a id='2976' tid='2975' class='u'>if</a> (<a id='2978' tid='2977' class='u'>or</a> (<a id='2980' tid='2979' class='u'>and</a> (<a id='2982' tid='2981' class='u'>not</a> <a id='2984' tid='2983' class='u'>firstp</a>)
                       (<a id='2986' tid='2985' class='u'>not</a> <a id='2988' tid='2987' class='u'>kill-whole-line</a>)
                       (<a id='2990' tid='2989' class='u'>eobp</a>))
                  (<a id='2992' tid='2991' class='u'>paredit-handle-sexp-errors</a>
                      (<a id='2994' tid='2993' class='u'>progn</a> (<a id='2996' tid='2995' class='u'>backward-sexp</a>) <a id='2998' tid='2997' class='u'>nil</a>)
                    <a id='3000' tid='2999' class='u'>t</a>)
                  (<a id='3002' tid='3001' class='u'>not</a> (<a id='3004' tid='3003' class='u'>eq</a> (<a id='3006' tid='3005' class='u'>point-at-eol</a>) <a id='3008' tid='3007' class='u'>eol</a>)))
              (<a id='3010' tid='3009' class='u'>throw</a> <a id='3012' tid='3011' class='u'>&#39;</a><a id='3014' tid='3013' class='u'>return</a> <a id='3016' tid='3015' class='u'>nil</a>)))
        (<a id='3018' tid='3017' class='u'>forward-sexp</a>)
        (<a id='3020' tid='3019' class='u'>if</a> (<a id='3022' tid='3021' class='u'>and</a> <a id='3024' tid='3023' class='u'>firstp</a>
                 (<a id='3026' tid='3025' class='u'>not</a> <a id='3028' tid='3027' class='u'>kill-whole-line</a>)
                 (<a id='3030' tid='3029' class='u'>eobp</a>))
            (<a id='3032' tid='3031' class='u'>throw</a> <a id='3034' tid='3033' class='u'>&#39;</a><a id='3036' tid='3035' class='u'>return</a> <a id='3038' tid='3037' class='u'>nil</a>))
        (<a id='3040' tid='3039' class='u'>setq</a> <a id='3042' tid='3041' class='u'>firstp</a> <a id='3044' tid='3043' class='u'>nil</a>)))
    <a id='3046' tid='3045' class='u'>end-of-list-p</a>))

(<a id='3764' tid='3763' class='u'>defun</a> <a id='3766' tid='3765' class='u'>paredit-kill-sexps-on-whole-line</a> (<a id='3768' tid='3767' class='u'>beginning</a>)
  (<a id='3770' tid='3769' class='u'>kill-region</a> <a id='3772' tid='3771' class='u'>beginning</a>
               (<a id='3774' tid='3773' class='u'>or</a> (<a id='3776' tid='3775' class='u'>save-excursion</a>     <a id='3778' tid='3777' class='u'>; Delete trailing indentation...
</a>                     (<a id='3780' tid='3779' class='u'>paredit-skip-whitespace</a> <a id='3782' tid='3781' class='u'>t</a>)
                     (<a id='3784' tid='3783' class='u'>and</a> (<a id='3786' tid='3785' class='u'>not</a> (<a id='3788' tid='3787' class='u'>eq</a> (<a id='3790' tid='3789' class='u'>char-after</a>) <a id='3792' tid='3791' class='u'>?\;</a> ))
                          (<a id='3794' tid='3793' class='u'>point</a>)))
                   <a id='3796' tid='3795' class='u'>;; ...or just use the point past the newline, if
</a>                   <a id='3798' tid='3797' class='u'>;; we encounter a comment.
</a>                   (<a id='3800' tid='3799' class='u'>point-at-eol</a>)))
  (<a id='3802' tid='3801' class='u'>cond</a> ((<a id='3804' tid='3803' class='u'>save-excursion</a> (<a id='3806' tid='3805' class='u'>paredit-skip-whitespace</a> <a id='3808' tid='3807' class='u'>nil</a> (<a id='3810' tid='3809' class='u'>point-at-bol</a>))
                         (<a id='3812' tid='3811' class='u'>bolp</a>))
         <a id='3814' tid='3813' class='u'>;; Nothing but indentation before the point, so indent it.
</a>         (<a id='3816' tid='3815' class='u'>lisp-indent-line</a>))
        ((<a id='3818' tid='3817' class='u'>eobp</a>) <a id='3820' tid='3819' class='u'>nil</a>)       <a id='3822' tid='3821' class='u'>; Protect the CHAR-SYNTAX below against NIL.
</a>        <a id='3824' tid='3823' class='u'>;; Insert a space to avoid invalid joining if necessary.
</a>        ((<a id='3826' tid='3825' class='u'>let</a> ((<a id='3828' tid='3827' class='u'>syn-before</a> (<a id='3830' tid='3829' class='u'>char-syntax</a> (<a id='3832' tid='3831' class='u'>char-before</a>)))
               (<a id='3834' tid='3833' class='u'>syn-after</a>  (<a id='3836' tid='3835' class='u'>char-syntax</a> (<a id='3838' tid='3837' class='u'>char-after</a>))))
           (<a id='3840' tid='3839' class='u'>or</a> (<a id='3842' tid='3841' class='u'>and</a> (<a id='3844' tid='3843' class='u'>eq</a> <a id='3846' tid='3845' class='u'>syn-before</a> <a id='3848' tid='3847' class='u'>?\)</a> )            <a id='3850' tid='3849' class='u'>; Separate opposing
</a>                    (<a id='3852' tid='3851' class='u'>eq</a> <a id='3854' tid='3853' class='u'>syn-after</a>  <a id='3856' tid='3855' class='u'>?\(</a> ))           <a id='3858' tid='3857' class='u'>;   parentheses,
</a>               (<a id='3860' tid='3859' class='u'>and</a> (<a id='3862' tid='3861' class='u'>eq</a> <a id='3864' tid='3863' class='u'>syn-before</a> <a id='3866' tid='3865' class='u'>?\&quot;</a> )            <a id='3868' tid='3867' class='u'>; string delimiter
</a>                    (<a id='3870' tid='3869' class='u'>eq</a> <a id='3872' tid='3871' class='u'>syn-after</a>  <a id='3874' tid='3873' class='u'>?\&quot;</a> ))           <a id='3876' tid='3875' class='u'>;   pairs,
</a>               (<a id='3878' tid='3877' class='u'>and</a> (<a id='3880' tid='3879' class='u'>memq</a> <a id='3882' tid='3881' class='u'>syn-before</a> <a id='3884' tid='3883' class='u'>&#39;</a>(<a id='3886' tid='3885' class='u'>?_</a> <a id='3888' tid='3887' class='u'>?w</a>))      <a id='3890' tid='3889' class='u'>; or word or symbol
</a>                    (<a id='3892' tid='3891' class='u'>memq</a> <a id='3894' tid='3893' class='u'>syn-after</a>  <a id='3896' tid='3895' class='u'>&#39;</a>(<a id='3898' tid='3897' class='u'>?_</a> <a id='3900' tid='3899' class='u'>?w</a>)))))   <a id='3902' tid='3901' class='u'>;   constituents.
</a>         (<a id='3904' tid='3903' class='u'>insert</a> <a id='3906' tid='3905' class='u'>&quot; &quot;</a>))))

<span class='i'>;;;;; Killing Words
</span>
<span class='i'>;;; This is tricky and asymmetrical because backward parsing is
</span><span class='i'>;;; extraordinarily difficult or impossible, so we have to implement
</span><span class='i'>;;; killing in both directions by parsing forward.
</span>
(<a id='2760' tid='2759' class='u'>defun</a> <a id='2762' tid='2761' class='u'>paredit-forward-kill-word</a> ()
  <a id='2764' tid='2763' class='u'>&quot;Kill a word forward, skipping over intervening delimiters.&quot;</a>
  (<a id='2766' tid='2765' class='u'>interactive</a>)
  (<a id='2768' tid='2767' class='u'>let</a> ((<a id='2770' tid='2769' class='u'>beginning</a> (<a id='2772' tid='2771' class='u'>point</a>)))
    (<a id='2774' tid='2773' class='u'>skip-syntax-forward</a> <a id='2776' tid='2775' class='u'>&quot; -&quot;</a>)
    (<a id='2778' tid='2777' class='u'>let*</a> ((<a id='2780' tid='2779' class='u'>parse-state</a> (<a id='2782' tid='2781' class='u'>paredit-current-parse-state</a>))
           (<a id='2784' tid='2783' class='u'>state</a> (<a id='2786' tid='2785' class='u'>paredit-kill-word-state</a> <a id='2788' tid='2787' class='u'>parse-state</a> <a id='2790' tid='2789' class='u'>&#39;</a><a id='2792' tid='2791' class='u'>char-after</a>)))
      (<a id='2794' tid='2793' class='u'>while</a> (<a id='2796' tid='2795' class='u'>not</a> (<a id='2798' tid='2797' class='u'>or</a> (<a id='2800' tid='2799' class='u'>eobp</a>)
                      (<a id='2802' tid='2801' class='u'>eq</a> <a id='2804' tid='2803' class='u'>?w</a> (<a id='2806' tid='2805' class='u'>char-syntax</a> (<a id='2808' tid='2807' class='u'>char-after</a>)))))
        (<a id='2810' tid='2809' class='u'>setq</a> <a id='2812' tid='2811' class='u'>parse-state</a>
              (<a id='2814' tid='2813' class='u'>progn</a> (<a id='2816' tid='2815' class='u'>forward-char</a> <a id='2818' tid='2817' class='u'>1</a>) (<a id='2820' tid='2819' class='u'>paredit-current-parse-state</a>))
<a id='2822' tid='2821' class='u'>;;               (parse-partial-sexp (point) (1+ (point))
</a><a id='2824' tid='2823' class='u'>;;                                   nil nil parse-state)
</a>              )
        (<a id='2826' tid='2825' class='u'>let*</a> ((<a id='2828' tid='2827' class='u'>old-state</a> <a id='2830' tid='2829' class='u'>state</a>)
               (<a id='2832' tid='2831' class='u'>new-state</a>
                (<a id='2834' tid='2833' class='u'>paredit-kill-word-state</a> <a id='2836' tid='2835' class='u'>parse-state</a> <a id='2838' tid='2837' class='u'>&#39;</a><a id='2840' tid='2839' class='u'>char-after</a>)))
          (<a id='2842' tid='2841' class='u'>cond</a> ((<a id='2844' tid='2843' class='u'>not</a> (<a id='2846' tid='2845' class='u'>eq</a> <a id='2848' tid='2847' class='u'>old-state</a> <a id='2850' tid='2849' class='u'>new-state</a>))
                 (<a id='2852' tid='2851' class='u'>setq</a> <a id='2854' tid='2853' class='u'>parse-state</a>
                       (<a id='2856' tid='2855' class='u'>paredit-kill-word-hack</a> <a id='2858' tid='2857' class='u'>old-state</a>
                                               <a id='2860' tid='2859' class='u'>new-state</a>
                                               <a id='2862' tid='2861' class='u'>parse-state</a>))
                 (<a id='2864' tid='2863' class='u'>setq</a> <a id='2866' tid='2865' class='u'>state</a>
                       (<a id='2868' tid='2867' class='u'>paredit-kill-word-state</a> <a id='2870' tid='2869' class='u'>parse-state</a>
                                                <a id='2872' tid='2871' class='u'>&#39;</a><a id='2874' tid='2873' class='u'>char-after</a>))
                 (<a id='2876' tid='2875' class='u'>setq</a> <a id='2878' tid='2877' class='u'>beginning</a> (<a id='2880' tid='2879' class='u'>point</a>)))))))
    (<a id='2882' tid='2881' class='u'>goto-char</a> <a id='2884' tid='2883' class='u'>beginning</a>)
    (<a id='2886' tid='2885' class='u'>kill-word</a> <a id='2888' tid='2887' class='u'>1</a>)))

(<a id='1972' tid='1971' class='u'>defun</a> <a id='1974' tid='1973' class='u'>paredit-backward-kill-word</a> ()
  <a id='1976' tid='1975' class='u'>&quot;Kill a word backward, skipping over any intervening delimiters.&quot;</a>
  (<a id='1978' tid='1977' class='u'>interactive</a>)
  (<a id='1980' tid='1979' class='u'>if</a> (<a id='1982' tid='1981' class='u'>not</a> (<a id='1984' tid='1983' class='u'>or</a> (<a id='1986' tid='1985' class='u'>bobp</a>)
               (<a id='1988' tid='1987' class='u'>eq</a> (<a id='1990' tid='1989' class='u'>char-syntax</a> (<a id='1992' tid='1991' class='u'>char-before</a>)) <a id='1994' tid='1993' class='u'>?w</a>)))
      (<a id='1996' tid='1995' class='u'>let</a> ((<a id='1998' tid='1997' class='u'>end</a> (<a id='2000' tid='1999' class='u'>point</a>)))
        (<a id='2002' tid='2001' class='u'>backward-word</a> <a id='2004' tid='2003' class='u'>1</a>)
        (<a id='2006' tid='2005' class='u'>forward-word</a> <a id='2008' tid='2007' class='u'>1</a>)
        (<a id='2010' tid='2009' class='u'>goto-char</a> (<a id='2012' tid='2011' class='u'>min</a> <a id='2014' tid='2013' class='u'>end</a> (<a id='2016' tid='2015' class='u'>point</a>)))
        (<a id='2018' tid='2017' class='u'>let*</a> ((<a id='2020' tid='2019' class='u'>parse-state</a> (<a id='2022' tid='2021' class='u'>paredit-current-parse-state</a>))
               (<a id='2024' tid='2023' class='u'>state</a>
                (<a id='2026' tid='2025' class='u'>paredit-kill-word-state</a> <a id='2028' tid='2027' class='u'>parse-state</a> <a id='2030' tid='2029' class='u'>&#39;</a><a id='2032' tid='2031' class='u'>char-before</a>)))
          (<a id='2034' tid='2033' class='u'>while</a> (<a id='2036' tid='2035' class='u'>and</a> (<a id='2038' tid='2037' class='u'>&lt;</a> (<a id='2040' tid='2039' class='u'>point</a>) <a id='2042' tid='2041' class='u'>end</a>)
                      (<a id='2044' tid='2043' class='u'>progn</a>
                        (<a id='2046' tid='2045' class='u'>setq</a> <a id='2048' tid='2047' class='u'>parse-state</a>
                              (<a id='2050' tid='2049' class='u'>parse-partial-sexp</a> (<a id='2052' tid='2051' class='u'>point</a>) (<a id='2054' tid='2053' class='u'>1+</a> (<a id='2056' tid='2055' class='u'>point</a>))
                                                  <a id='2058' tid='2057' class='u'>nil</a> <a id='2060' tid='2059' class='u'>nil</a> <a id='2062' tid='2061' class='u'>parse-state</a>))
                        (<a id='2064' tid='2063' class='u'>or</a> (<a id='2066' tid='2065' class='u'>eq</a> <a id='2068' tid='2067' class='u'>state</a>
                                (<a id='2070' tid='2069' class='u'>paredit-kill-word-state</a> <a id='2072' tid='2071' class='u'>parse-state</a>
                                                         <a id='2074' tid='2073' class='u'>&#39;</a><a id='2076' tid='2075' class='u'>char-before</a>))
                            (<a id='2078' tid='2077' class='u'>progn</a> (<a id='2080' tid='2079' class='u'>backward-char</a> <a id='2082' tid='2081' class='u'>1</a>) <a id='2084' tid='2083' class='u'>nil</a>)))))
          (<a id='2086' tid='2085' class='u'>if</a> (<a id='2088' tid='2087' class='u'>and</a> (<a id='2090' tid='2089' class='u'>eq</a> <a id='2092' tid='2091' class='u'>state</a> <a id='2094' tid='2093' class='u'>&#39;</a><a id='2096' tid='2095' class='u'>comment</a>)
                   (<a id='2098' tid='2097' class='u'>eq</a> <a id='2100' tid='2099' class='u'>?\#</a> (<a id='2102' tid='2101' class='u'>char-after</a> (<a id='2104' tid='2103' class='u'>point</a>)))
                   (<a id='2106' tid='2105' class='u'>eq</a> <a id='2108' tid='2107' class='u'>?\|</a> (<a id='2110' tid='2109' class='u'>char-before</a> (<a id='2112' tid='2111' class='u'>point</a>))))
              (<a id='2114' tid='2113' class='u'>backward-char</a> <a id='2116' tid='2115' class='u'>1</a>)))))
  (<a id='2118' tid='2117' class='u'>backward-kill-word</a> <a id='2120' tid='2119' class='u'>1</a>))

<span class='i'>;;;;;; Word-Killing Auxiliaries
</span>
(<a id='4014' tid='4013' class='u'>defun</a> <a id='4016' tid='4015' class='u'>paredit-kill-word-state</a> (<a id='4018' tid='4017' class='u'>parse-state</a> <a id='4020' tid='4019' class='u'>adjacent-char-fn</a>)
  (<a id='4022' tid='4021' class='u'>cond</a> ((<a id='4024' tid='4023' class='u'>paredit-in-comment-p</a> <a id='4026' tid='4025' class='u'>parse-state</a>) <a id='4028' tid='4027' class='u'>&#39;</a><a id='4030' tid='4029' class='u'>comment</a>)
        ((<a id='4032' tid='4031' class='u'>paredit-in-string-p</a>  <a id='4034' tid='4033' class='u'>parse-state</a>) <a id='4036' tid='4035' class='u'>&#39;</a><a id='4038' tid='4037' class='u'>string</a>)
        ((<a id='4040' tid='4039' class='u'>memq</a> (<a id='4042' tid='4041' class='u'>char-syntax</a> (<a id='4044' tid='4043' class='u'>funcall</a> <a id='4046' tid='4045' class='u'>adjacent-char-fn</a>))
               <a id='4048' tid='4047' class='u'>&#39;</a>(<a id='4050' tid='4049' class='u'>?\(</a> <a id='4052' tid='4051' class='u'>?\)</a> ))
         <a id='4054' tid='4053' class='u'>&#39;</a><a id='4056' tid='4055' class='u'>delimiter</a>)
        (<a id='4058' tid='4057' class='u'>t</a> <a id='4060' tid='4059' class='u'>&#39;</a><a id='4062' tid='4061' class='u'>other</a>)))

<span class='i'>;;; This optionally advances the point past any comment delimiters that
</span><span class='i'>;;; should probably not be touched, based on the last state change and
</span><span class='i'>;;; the characters around the point.  It returns a new parse state,
</span><span class='i'>;;; starting from the PARSE-STATE parameter.
</span>
(<a id='3912' tid='3911' class='u'>defun</a> <a id='3914' tid='3913' class='u'>paredit-kill-word-hack</a> (<a id='3916' tid='3915' class='u'>old-state</a> <a id='3918' tid='3917' class='u'>new-state</a> <a id='3920' tid='3919' class='u'>parse-state</a>)
  (<a id='3922' tid='3921' class='u'>cond</a> ((<a id='3924' tid='3923' class='u'>and</a> (<a id='3926' tid='3925' class='u'>not</a> (<a id='3928' tid='3927' class='u'>eq</a> <a id='3930' tid='3929' class='u'>old-state</a> <a id='3932' tid='3931' class='u'>&#39;</a><a id='3934' tid='3933' class='u'>comment</a>))
              (<a id='3936' tid='3935' class='u'>not</a> (<a id='3938' tid='3937' class='u'>eq</a> <a id='3940' tid='3939' class='u'>new-state</a> <a id='3942' tid='3941' class='u'>&#39;</a><a id='3944' tid='3943' class='u'>comment</a>))
              (<a id='3946' tid='3945' class='u'>not</a> (<a id='3948' tid='3947' class='u'>paredit-in-string-escape-p</a>))
              (<a id='3950' tid='3949' class='u'>eq</a> <a id='3952' tid='3951' class='u'>?\#</a> (<a id='3954' tid='3953' class='u'>char-before</a>))
              (<a id='3956' tid='3955' class='u'>eq</a> <a id='3958' tid='3957' class='u'>?\|</a> (<a id='3960' tid='3959' class='u'>char-after</a>)))
         (<a id='3962' tid='3961' class='u'>forward-char</a> <a id='3964' tid='3963' class='u'>1</a>)
         (<a id='3966' tid='3965' class='u'>paredit-current-parse-state</a>)
<a id='3968' tid='3967' class='u'>;;          (parse-partial-sexp (point) (1+ (point))
</a><a id='3970' tid='3969' class='u'>;;                              nil nil parse-state)
</a>         )
        ((<a id='3972' tid='3971' class='u'>and</a> (<a id='3974' tid='3973' class='u'>not</a> (<a id='3976' tid='3975' class='u'>eq</a> <a id='3978' tid='3977' class='u'>old-state</a> <a id='3980' tid='3979' class='u'>&#39;</a><a id='3982' tid='3981' class='u'>comment</a>))
              (<a id='3984' tid='3983' class='u'>eq</a> <a id='3986' tid='3985' class='u'>new-state</a> <a id='3988' tid='3987' class='u'>&#39;</a><a id='3990' tid='3989' class='u'>comment</a>)
              (<a id='3992' tid='3991' class='u'>eq</a> <a id='3994' tid='3993' class='u'>?\;</a> (<a id='3996' tid='3995' class='u'>char-before</a>)))
         (<a id='3998' tid='3997' class='u'>skip-chars-forward</a> <a id='4000' tid='3999' class='u'>&quot;;&quot;</a>)
         (<a id='4002' tid='4001' class='u'>paredit-current-parse-state</a>)
<a id='4004' tid='4003' class='u'>;;          (parse-partial-sexp (point) (save-excursion
</a><a id='4006' tid='4005' class='u'>;;                                        (skip-chars-forward &quot;;&quot;))
</a><a id='4008' tid='4007' class='u'>;;                              nil nil parse-state)
</a>         )
        (<a id='4010' tid='4009' class='u'>t</a> <a id='4012' tid='4011' class='u'>parse-state</a>)))

<span class='i'>(defun paredit-copy-as-kill ()
  &quot;Save in the kill ring the region that `paredit-kill&#39; would kill.&quot;
  (interactive)
  (cond ((paredit-in-string-p)
         (paredit-copy-as-kill-in-string))
        ((paredit-in-comment-p)
         (copy-region-as-kill (point) (point-at-eol)))
        ((save-excursion (paredit-skip-whitespace t (point-at-eol))
                         (or (eolp) (eq (char-after) ?\; )))
         ;** Be careful about trailing backslashes.
         (save-excursion
           (if (paredit-in-char-p)
               (backward-char))
           (copy-region-as-kill (point) (point-at-eol))))
        (t (paredit-copy-sexps-as-kill))))</span>

<span class='i'>(defun paredit-copy-as-kill-in-string ()
  (save-excursion
    (if (paredit-in-string-escape-p)
        (backward-char))
    (copy-region-as-kill (point)
                         (min (point-at-eol)
                              (cdr (paredit-string-start+end-points))))))</span>

<span class='i'>(defun paredit-copy-sexps-as-kill ()
  (save-excursion
    (if (paredit-in-char-p)
        (backward-char 2))
    (let ((beginning (point))
          (eol (point-at-eol)))
      (let ((end-of-list-p (paredit-forward-sexps-to-kill beginning eol)))
        (if end-of-list-p (progn (up-list) (backward-char)))
        (copy-region-as-kill beginning
                             (cond (kill-whole-line
                                    (or (save-excursion
                                          (paredit-skip-whitespace t)
                                          (and (not (eq (char-after) ?\; ))
                                               (point)))
                                        (point-at-eol)))
                                   ((and (not end-of-list-p)
                                         (eq (point-at-eol) eol))
                                    eol)
                                   (t
                                    (point))))))))</span>

<span class='i'>;;;; Safe Region Killing/Copying
</span>
<span class='i'>;;; This is an experiment.  It&#39;s not enough: `paredit-kill-ring-save&#39;
</span><span class='i'>;;; is always safe; it&#39;s `yank&#39; that&#39;s not safe, but even trickier to
</span><span class='i'>;;; implement than `paredit-kill-region&#39;.  Also, the heuristics for
</span><span class='i'>;;; `paredit-kill-region&#39; are slightly too conservative -- they will
</span><span class='i'>;;; sometimes reject killing regions that would be safe to kill.
</span><span class='i'>;;; (Consider, e,g., a region that starts in a comment and ends in the
</span><span class='i'>;;; middle of a symbol at the end of a line: that&#39;s safe to kill, but
</span><span class='i'>;;; `paredit-kill-region&#39; won&#39;t allow it.)  I don&#39;t know whether they
</span><span class='i'>;;; are too liberal: I haven&#39;t constructed a region that is unsafe to
</span><span class='i'>;;; kill but which `paredit-kill-region&#39; will kill, but I haven&#39;t ruled
</span><span class='i'>;;; out the possibility either.
</span>
<span class='i'>(defun paredit-kill-ring-save (beginning end)
  &quot;Save the balanced region, but don&#39;t kill it, like `kill-ring-save&#39;.
If the text of the region is imbalanced, signal an error instead.
With a prefix argument, disregard any imbalance.&quot;
  (interactive &quot;r&quot;)
  (if (not current-prefix-arg)
      (paredit-check-region beginning end))
  (setq this-command &#39;kill-ring-save)
  (kill-ring-save beginning end))</span>

<span class='i'>(defun paredit-kill-region (beginning end &optional yank-handler)
  &quot;Kill balanced text between point and mark, like `kill-region&#39;.
If that text is imbalanced, signal an error instead.&quot;
  (interactive &quot;r&quot;)
  (if (and beginning end)
      ;; Check that region begins and ends in a sufficiently similar
      ;; state, so that deleting it will leave the buffer balanced.
      (save-excursion
        (goto-char beginning)
        (let* ((state (paredit-current-parse-state))
               (state* (parse-partial-sexp beginning end nil nil state)))
          (paredit-check-region-state state state*))))
  (setq this-command &#39;kill-region)
  (kill-region beginning end yank-handler))</span>

<span class='i'>(defun paredit-check-region-state (beginning-state end-state)
  (paredit-check-region-state-depth beginning-state end-state)
  (paredit-check-region-state-string beginning-state end-state)
  (paredit-check-region-state-comment beginning-state end-state)
  (paredit-check-region-state-char-quote beginning-state end-state))</span>

<span class='i'>(defun paredit-check-region-state-depth (beginning-state end-state)
  (let ((beginning-depth (nth 0 beginning-state))
        (end-depth (nth 0 end-state)))
    (if (not (= beginning-depth end-depth))
        (error &quot;Mismatched parenthesis depth: %S at start, %S at end.&quot;
               beginning-depth
               end-depth))))</span>

<span class='i'>(defun paredit-check-region-state-string (beginning-state end-state)
  (let ((beginning-string-p (nth 3 beginning-state))
        (end-string-p (nth 3 end-state)))
    (if (not (eq beginning-string-p end-string-p))
        (error &quot;Mismatched string state: start %sin string, end %sin string.&quot;
               (if beginning-string-p &quot;&quot; &quot;not &quot;)
               (if end-string-p &quot;&quot; &quot;not &quot;)))))</span>

<span class='i'>(defun paredit-check-region-state-comment (beginning-state end-state)
  (let ((beginning-comment-state (nth 4 beginning-state))
        (end-comment-state (nth 4 end-state)))
    (if (not (or (eq beginning-comment-state end-comment-state)
                 (and (eq beginning-comment-state nil)
                      (eq end-comment-state t)
                      (eolp))))
        (error &quot;Mismatched comment state: %s&quot;
               (cond ((and (integerp beginning-comment-state)
                           (integerp end-comment-state))
                      (format &quot;depth %S at start, depth %S at end.&quot;
                              beginning-comment-state
                              end-comment-state))
                     ((integerp beginning-comment-state)
                      &quot;start in nested comment, end otherwise.&quot;)
                     ((integerp end-comment-state)
                      &quot;end in nested comment, start otherwise.&quot;)
                     (beginning-comment-state
                      &quot;start in comment, end not in comment.&quot;)
                     (end-comment-state
                      &quot;end in comment, start not in comment.&quot;)
                     (t
                      (format &quot;start %S, end %S.&quot;
                              beginning-comment-state
                              end-comment-state)))))))</span>

<span class='i'>(defun paredit-check-region-state-char-quote (beginning-state end-state)
  (let ((beginning-char-quote (nth 5 beginning-state))
        (end-char-quote (nth 5 end-state)))
    (if (not (eq beginning-char-quote end-char-quote))
        (let ((phrase &quot;character quotation&quot;))
          (error &quot;Mismatched %s: start %sin %s, end %sin %s.&quot;
                 phrase
                 (if beginning-char-quote &quot;&quot; &quot;not &quot;)
                 phrase
                 (if end-char-quote &quot;&quot; &quot;not &quot;)
                 phrase)))))</span>

<span class='i'>;;;; Cursor and Screen Movement
</span>
(<a id='4788' tid='4787' class='u'>eval-and-compile</a>
  (<a id='4826' tid='4825' class='u'>defmacro</a> <a id='4828' tid='4827' class='u'>defun-saving-mark</a> (<a id='4830' tid='4829' class='u'>name</a> <a id='4832' tid='4831' class='u'>bvl</a> <a id='4834' tid='4833' class='u'>doc</a> <a id='4836' tid='4835' class='u'>&rest</a> <a id='4838' tid='4837' class='u'>body</a>)
    <a id='4840' tid='4839' class='u'>`</a>(<a id='4790' tid='4789' class='u'>defun</a> <a id='4792' tid='4791' class='u'>,</a><a id='4794' tid='4793' class='u'>name</a> <a id='4796' tid='4795' class='u'>,</a><a id='4798' tid='4797' class='u'>bvl</a>
       <a id='4800' tid='4799' class='u'>,</a><a id='4802' tid='4801' class='u'>doc</a>
       <a id='4804' tid='4803' class='u'>,</a>(<a id='4806' tid='4805' class='u'>xcond</a> ((<a id='4808' tid='4807' class='u'>paredit-xemacs-p</a>)
                <a id='4810' tid='4809' class='u'>&#39;</a>(<a id='4812' tid='4811' class='u'>interactive</a> <a id='4814' tid='4813' class='u'>&quot;_&quot;</a>))
               ((<a id='4816' tid='4815' class='u'>paredit-gnu-emacs-p</a>)
                <a id='4818' tid='4817' class='u'>&#39;</a>(<a id='4820' tid='4819' class='u'>interactive</a>)))
       <a id='4822' tid='4821' class='u'>,</a><a id='4824' tid='4823' class='u'>@body</a>)))

(<a id='4842' tid='4841' class='u'>defun-saving-mark</a> <a id='4844' tid='4843' class='u'>paredit-forward</a> ()
  <a id='4846' tid='4845' class='u'>&quot;Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
  delimiter, move past that closing delimiter; otherwise, move forward
  past the S-expression following the point.&quot;</a>
  (<a id='4848' tid='4847' class='u'>paredit-handle-sexp-errors</a>
      (<a id='4850' tid='4849' class='u'>forward-sexp</a>)
    <a id='4852' tid='4851' class='u'>;++ Is it necessary to use UP-LIST and not just FORWARD-CHAR?
</a>    (<a id='4854' tid='4853' class='u'>if</a> (<a id='4856' tid='4855' class='u'>paredit-in-string-p</a>) (<a id='4858' tid='4857' class='u'>forward-char</a>) (<a id='4860' tid='4859' class='u'>up-list</a>))))

(<a id='4862' tid='4861' class='u'>defun-saving-mark</a> <a id='4864' tid='4863' class='u'>paredit-backward</a> ()
  <a id='4866' tid='4865' class='u'>&quot;Move backward an S-expression, or up an S-expression backward.
If there are no more S-expressions in this one before the opening
  delimiter, move past that opening delimiter backward; otherwise, move
  move backward past the S-expression preceding the point.&quot;</a>
  (<a id='4868' tid='4867' class='u'>paredit-handle-sexp-errors</a>
      (<a id='4870' tid='4869' class='u'>backward-sexp</a>)
    (<a id='4872' tid='4871' class='u'>if</a> (<a id='4874' tid='4873' class='u'>paredit-in-string-p</a>) (<a id='4876' tid='4875' class='u'>backward-char</a>) (<a id='4878' tid='4877' class='u'>backward-up-list</a>))))

<a id='4880' tid='4879' class='u'>;;; Why is this not in lisp.el?
</a>
(<a id='1494' tid='1493' class='u'>defun</a> <a id='1496' tid='1495' class='u'>backward-down-list</a> (<a id='1498' tid='1497' class='u'>&optional</a> <a id='1500' tid='1499' class='u'>arg</a>)
  <a id='1502' tid='1501' class='u'>&quot;Move backward and descend into one level of parentheses.
With ARG, do this that many times.
A negative argument means move forward but still descend a level.&quot;</a>
  (<a id='1504' tid='1503' class='u'>interactive</a> <a id='1506' tid='1505' class='u'>&quot;p&quot;</a>)
  (<a id='1508' tid='1507' class='u'>down-list</a> (<a id='1510' tid='1509' class='u'>-</a> (<a id='1512' tid='1511' class='u'>or</a> <a id='1514' tid='1513' class='u'>arg</a> <a id='1516' tid='1515' class='u'>1</a>))))

<a id='4882' tid='4881' class='u'>;;; Thanks to Marco Baringer for suggesting & writing this function.
</a>
(<a id='4264' tid='4263' class='u'>defun</a> <a id='4266' tid='4265' class='u'>paredit-recentre-on-sexp</a> (<a id='4268' tid='4267' class='u'>&optional</a> <a id='4270' tid='4269' class='u'>n</a>)
  <a id='4272' tid='4271' class='u'>&quot;Recentre the screen on the S-expression following the point.
With a prefix argument N, encompass all N S-expressions forward.&quot;</a>
  (<a id='4274' tid='4273' class='u'>interactive</a> <a id='4276' tid='4275' class='u'>&quot;P&quot;</a>)
  (<a id='4278' tid='4277' class='u'>save-excursion</a>
    (<a id='4280' tid='4279' class='u'>forward-sexp</a> <a id='4282' tid='4281' class='u'>n</a>)
    (<a id='4284' tid='4283' class='u'>let</a> ((<a id='4286' tid='4285' class='u'>end-point</a> (<a id='4288' tid='4287' class='u'>point</a>)))
      (<a id='4290' tid='4289' class='u'>backward-sexp</a> <a id='4292' tid='4291' class='u'>n</a>)
      (<a id='4294' tid='4293' class='u'>let*</a> ((<a id='4296' tid='4295' class='u'>start-point</a> (<a id='4298' tid='4297' class='u'>point</a>))
             (<a id='4300' tid='4299' class='u'>start-line</a> (<a id='4302' tid='4301' class='u'>count-lines</a> (<a id='4304' tid='4303' class='u'>point-min</a>) (<a id='4306' tid='4305' class='u'>point</a>)))
             (<a id='4308' tid='4307' class='u'>lines-on-sexps</a> (<a id='4310' tid='4309' class='u'>count-lines</a> <a id='4312' tid='4311' class='u'>start-point</a> <a id='4314' tid='4313' class='u'>end-point</a>)))
        (<a id='4316' tid='4315' class='u'>goto-line</a> (<a id='4318' tid='4317' class='u'>+</a> <a id='4320' tid='4319' class='u'>start-line</a> (<a id='4322' tid='4321' class='u'>/</a> <a id='4324' tid='4323' class='u'>lines-on-sexps</a> <a id='4326' tid='4325' class='u'>2</a>)))
        (<a id='4328' tid='4327' class='u'>recenter</a>)))))

<span class='i'>(defun paredit-focus-on-defun ()
  &quot;Moves display to the top of the definition at point.&quot;
  (interactive)
  (beginning-of-defun)
  (recenter 0))</span>

<span class='i'>;;;; Generalized Upward/Downward Motion
</span>
<span class='i'>(defun paredit-up/down (n vertical-direction)
  (let ((horizontal-direction (if (&lt; 0 n) +1 -1)))
    (while (/= n 0)
      (goto-char
       (paredit-next-up/down-point horizontal-direction vertical-direction))
      (setq n (- n horizontal-direction)))))</span>

<span class='i'>(defun paredit-next-up/down-point (horizontal-direction vertical-direction)
  (let ((state (paredit-current-parse-state))
        (scan-lists
         (lambda ()
           (scan-lists (point) horizontal-direction vertical-direction))))
    (cond ((paredit-in-string-p state)
           (let ((start+end (paredit-string-start+end-points state)))
             (if (&lt; 0 vertical-direction)
                 (if (&lt; 0 horizontal-direction)
                     (+ 1 (cdr start+end))
                     (car start+end))
                 ;; We could let the user try to descend into lists
                 ;; within the string, but that would be asymmetric
                 ;; with the up case, which rises out of the whole
                 ;; string and not just out of a list within the
                 ;; string, so this case will just be an error.
                 (error &quot;Can&#39;t descend further into string.&quot;))))
          ((&lt; 0 vertical-direction)
           ;; When moving up, just try to rise up out of the list.
           (or (funcall scan-lists)
               (buffer-end horizontal-direction)))
          ((&lt; vertical-direction 0)
           ;; When moving down, look for a string closer than a list,
           ;; and use that if we find it.
           (let* ((list-start
                   (paredit-handle-sexp-errors (funcall scan-lists) nil))
                  (string-start
                   (paredit-find-next-string-start horizontal-direction
                                                   list-start)))
             (if (and string-start list-start)
                 (if (&lt; 0 horizontal-direction)
                     (min string-start list-start)
                     (max string-start list-start))
                 (or string-start
                     ;; Scan again: this is a kludgey way to report the
                     ;; error if there really was one.
                     (funcall scan-lists)
                     (buffer-end horizontal-direction)))))
          (t
           (error &quot;Vertical direction must be nonzero in `%s&#39;.&quot;
                  &#39;paredit-up/down)))))</span>

<span class='i'>(defun paredit-find-next-string-start (horizontal-direction limit)
  (let ((next-char (if (&lt; 0 horizontal-direction) &#39;char-after &#39;char-before))
        (pastp (if (&lt; 0 horizontal-direction) &#39;&lt; &#39;&gt;)))
    (paredit-handle-sexp-errors
        (save-excursion
          (catch &#39;exit
            (while t
              (if (and limit (funcall pastp (point) limit))
                  (throw &#39;exit nil))
              (forward-sexp horizontal-direction)
              (save-excursion
                (backward-sexp horizontal-direction)
                (if (eq ?\&quot; (char-syntax (funcall next-char)))
                    (throw &#39;exit (+ (point) horizontal-direction)))))))
      nil)))</span>

<span class='i'>(defun paredit-forward-down (&optional argument)
  &quot;Move forward down into a list.
With a positive argument, move forward down that many levels.
With a negative argument, move backward down that many levels.&quot;
  (interactive &quot;p&quot;)
  (paredit-up/down (or argument +1) -1))</span>

<span class='i'>(defun paredit-backward-up (&optional argument)
  &quot;Move backward up out of the enclosing list.
With a positive argument, move backward up that many levels.
With a negative argument, move forward up that many levels.
If in a string initially, that counts as one level.&quot;
  (interactive &quot;p&quot;)
  (paredit-up/down (- 0 (or argument +1)) +1))</span>

<span class='i'>(defun paredit-forward-up (&optional argument)
  &quot;Move forward up out of the enclosing list.
With a positive argument, move forward up that many levels.
With a negative argument, move backward up that many levels.
If in a string initially, that counts as one level.&quot;
  (interactive &quot;p&quot;)
  (paredit-up/down (or argument +1) +1))</span>

<span class='i'>(defun paredit-backward-down (&optional argument)
  &quot;Move backward down into a list.
With a positive argument, move backward down that many levels.
With a negative argument, move forward down that many levels.&quot;
  (interactive &quot;p&quot;)
  (paredit-up/down (- 0 (or argument +1)) -1))</span>

<span class='i'>;;;; Depth-Changing Commands:  Wrapping, Splicing, & Raising
</span>
(<a id='4614' tid='4613' class='u'>defun</a> <a id='4616' tid='4615' class='u'>paredit-wrap-sexp</a> <span class='i'>(&optional argument open close)</span>
  <span class='i'>&quot;Wrap the following S-expression.
If a `C-u&#39; prefix argument is given, wrap all S-expressions following
  the point until the end of the buffer or of the enclosing list.
If a numeric prefix argument N is given, wrap N S-expressions.
Automatically indent the newly wrapped S-expression.
As a special case, if the point is at the end of a list, simply insert
  a parenthesis pair, rather than inserting a lone opening delimiter
  and then signalling an error, in the interest of preserving
  structure.
By default OPEN and CLOSE are round delimiters.&quot;</span>
  (<a id='4618' tid='4617' class='u'>interactive</a> <a id='4620' tid='4619' class='u'>&quot;P&quot;</a>)
  <span class='i'>(paredit-lose-if-not-in-sexp &#39;paredit-wrap-sexp)</span>
  <span class='i'>(let ((open (or open ?\( ))
        (close (or close ?\) )))
    (paredit-handle-sexp-errors
        ((lambda (n) (paredit-insert-pair n open close &#39;goto-char))
         (cond ((integerp argument) argument)
               ((consp argument) (paredit-count-sexps-forward))
               ((paredit-region-active-p) nil)
               (t 1)))
      (insert close)
      (backward-char)))</span>
  (<a id='4622' tid='4621' class='u'>save-excursion</a> (<a id='4624' tid='4623' class='u'>backward-up-list</a>) (<a id='4626' tid='4625' class='u'>indent-sexp</a>)))

<span class='i'>(defun paredit-count-sexps-forward ()
  (save-excursion
    (let ((n 0))
      (paredit-ignore-sexp-errors
        (while (not (eobp))
          (forward-sexp)
          (setq n (+ n 1))))
      n)))</span>

<span class='i'>(defun paredit-yank-pop (&optional argument)
  &quot;Replace just-yanked text with the next item in the kill ring.
If this command follows a `yank&#39;, just run `yank-pop&#39;.
If this command follows a `paredit-wrap-sexp&#39;, or any other paredit
  wrapping command (see `paredit-wrap-commands&#39;), run `yank&#39; and
  reindent the enclosing S-expression.
If this command is repeated, run `yank-pop&#39; and reindent the enclosing
  S-expression.

The argument is passed on to `yank&#39; or `yank-pop&#39;; see their
  documentation for details.&quot;
  (interactive &quot;*p&quot;)
  (cond ((eq last-command &#39;yank)
         (yank-pop argument))
        ((memq last-command paredit-wrap-commands)
         (yank argument)
         ;; `yank&#39; futzes with `this-command&#39;.
         (setq this-command &#39;paredit-yank-pop)
         (save-excursion (backward-up-list) (indent-sexp)))
        ((eq last-command &#39;paredit-yank-pop)
         ;; Pretend we just did a `yank&#39;, so that we can use
         ;; `yank-pop&#39; without duplicating its definition.
         (setq last-command &#39;yank)
         (yank-pop argument)
         ;; Return to our original state.
         (setq last-command &#39;paredit-yank-pop)
         (setq this-command &#39;paredit-yank-pop)
         (save-excursion (backward-up-list) (indent-sexp)))
        (t (error &quot;Last command was not a yank or a wrap: %s&quot; last-command))))</span>

<span class='i'>;;; Thanks to Marco Baringer for the suggestion of a prefix argument
</span><span class='i'>;;; for PAREDIT-SPLICE-SEXP.  (I, Taylor R. Campbell, however, still
</span><span class='i'>;;; implemented it, in case any of you lawyer-folk get confused by the
</span><span class='i'>;;; remark in the top of the file about explicitly noting code written
</span><span class='i'>;;; by other people.)
</span>
(<a id='4494' tid='4493' class='u'>defun</a> <a id='4496' tid='4495' class='u'>paredit-splice-sexp</a> <span class='i'>(&optional argument)</span>
  <span class='i'>&quot;Splice the list that the point is on by removing its delimiters.
With a prefix argument as in `C-u&#39;, kill all S-expressions backward in
  the current list before splicing all S-expressions forward into the
  enclosing list.
With two prefix arguments as in `C-u C-u&#39;, kill all S-expressions
  forward in the current list before splicing all S-expressions
  backward into the enclosing list.
With a numerical prefix argument N, kill N S-expressions backward in
  the current list before splicing the remaining S-expressions into the
  enclosing list.  If N is negative, kill forward.
Inside a string, unescape all backslashes, or signal an error if doing
  so would invalidate the buffer&#39;s structure.&quot;</span>
  (<a id='4498' tid='4497' class='u'>interactive</a> <a id='4500' tid='4499' class='u'>&quot;P&quot;</a>)
  <span class='i'>(if (paredit-in-string-p)
      (paredit-splice-string argument)
      (save-excursion
        (paredit-kill-surrounding-sexps-for-splice argument)
        (let ((end (point)))
          (backward-up-list)            ; Go up to the beginning...
          (save-excursion
            (forward-char 1)            ; (Skip over leading whitespace
            (paredit-skip-whitespace t end)
            (setq end (point)))         ;   for the `delete-region&#39;.)
          (let ((indent-start nil) (indent-end nil))
            (save-excursion
              (setq indent-start (point))
              (forward-sexp)            ; Go forward an expression, to
              (backward-delete-char 1)  ;   delete the end delimiter.
              (setq indent-end (point)))
            (delete-region (point) end) ; ...to delete the open char.
            ;; Reindent only the region we preserved.
            (indent-region indent-start indent-end)))))</span>)

(<a id='3908' tid='3907' class='u'>defun</a> <a id='3910' tid='3909' class='u'>paredit-kill-surrounding-sexps-for-splice</a> <span class='i'>(argument)</span>
  (<span class='i'>cond</span> <span class='i'>((or (paredit-in-string-p)
             (paredit-in-comment-p))
         (error &quot;Invalid context for splicing S-expressions.&quot;))</span>
        <span class='i'>((or (not argument) (eq argument 0)) nil)</span>
        <span class='i'>((or (numberp argument) (eq argument &#39;-))
         ;; Kill S-expressions before/after the point by saving the
         ;; point, moving across them, and killing the region.
         (let* ((argument (if (eq argument &#39;-) -1 argument))
                (saved (paredit-point-at-sexp-boundary (- argument))))
           (goto-char saved)
           (paredit-ignore-sexp-errors (backward-sexp argument))
           (paredit-hack-kill-region saved (point))))</span>
        (<span class='i'>(consp argument)</span>
         (<span class='i'>let</span> <span class='i'>((v (car argument)))</span>
           (<a id='1210' tid='1209' class='m'>if</a> (<a id='1212' tid='1211' class='m'>=</a> <a id='1214' tid='1213' class='m'>v</a> <a id='1216' tid='1215' class='m'>4</a>)                  <span class='i'>;One `C-u&#39;.
</span>               <a id='1218' tid='1217' class='m'>;; Move backward until we hit the open paren; then
</a>               <a id='1220' tid='1219' class='m'>;; kill that selected region.
</a>               (<span class='i'>let</span> <span class='i'>((end (point)))</span>
                 (<a id='1222' tid='1221' class='m'>paredit-ignore-sexp-errors</a>
                   (<a id='1224' tid='1223' class='m'>while</a> (<a id='1226' tid='1225' class='m'>not</a> (<a id='1228' tid='1227' class='m'>bobp</a>))
                     (<a id='1230' tid='1229' class='m'>backward-sexp</a>)))
                 <span class='i'>(paredit-hack-kill-region (point) end)</span>)
               <a id='1232' tid='1231' class='m'>;; Move forward until we hit the close paren; then
</a>               <a id='1234' tid='1233' class='m'>;; kill that selected region.
</a>               (<span class='i'>let</span> <span class='i'>((beginning (point)))</span>
                 (<a id='1236' tid='1235' class='m'>paredit-ignore-sexp-errors</a>
                   (<a id='1238' tid='1237' class='m'>while</a> (<a id='1240' tid='1239' class='m'>not</a> (<a id='1242' tid='1241' class='m'>eobp</a>))
                     (<a id='1244' tid='1243' class='m'>forward-sexp</a>)))
                 <span class='i'>(paredit-hack-kill-region beginning (point))</span>))))
        <span class='i'>(t (error &quot;Bizarre prefix argument `%s&#39;.&quot; argument))</span>))

(<a id='4502' tid='4501' class='u'>defun</a> <a id='4504' tid='4503' class='u'>paredit-splice-sexp-killing-backward</a> (<a id='4506' tid='4505' class='u'>&optional</a> <a id='4508' tid='4507' class='u'>n</a>)
  <a id='4510' tid='4509' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions before the point in the current list.
With a prefix argument N, kill only the preceding N S-expressions.&quot;</a>
  (<a id='4512' tid='4511' class='u'>interactive</a> <a id='4514' tid='4513' class='u'>&quot;P&quot;</a>)
  (<a id='4516' tid='4515' class='u'>paredit-splice-sexp</a> (<a id='4518' tid='4517' class='u'>if</a> <a id='4520' tid='4519' class='u'>n</a>
                           (<a id='4522' tid='4521' class='u'>prefix-numeric-value</a> <a id='4524' tid='4523' class='u'>n</a>)
                           <a id='4526' tid='4525' class='u'>&#39;</a>(<a id='4528' tid='4527' class='u'>4</a>))))

(<a id='4530' tid='4529' class='u'>defun</a> <a id='4532' tid='4531' class='u'>paredit-splice-sexp-killing-forward</a> (<a id='4534' tid='4533' class='u'>&optional</a> <a id='4536' tid='4535' class='u'>n</a>)
  <a id='4538' tid='4537' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions after the point in the current list.
With a prefix argument N, kill only the following N S-expressions.&quot;</a>
  (<a id='4540' tid='4539' class='u'>interactive</a> <a id='4542' tid='4541' class='u'>&quot;P&quot;</a>)
  (<a id='4544' tid='4543' class='u'>paredit-splice-sexp</a> (<a id='4546' tid='4545' class='u'>if</a> <a id='4548' tid='4547' class='u'>n</a>
                           (<a id='4550' tid='4549' class='u'>-</a> (<a id='4552' tid='4551' class='u'>prefix-numeric-value</a> <a id='4554' tid='4553' class='u'>n</a>))
                           <a id='4556' tid='4555' class='u'>&#39;</a>(<a id='4558' tid='4557' class='u'>16</a>))))

(<a id='4260' tid='4259' class='u'>defun</a> <a id='4262' tid='4261' class='u'>paredit-raise-sexp</a> <span class='i'>(&optional argument)</span>
  <span class='i'>&quot;Raise the following S-expression in a tree, deleting its siblings.
With a prefix argument N, raise the following N S-expressions.  If N
  is negative, raise the preceding N S-expressions.
If the point is on an S-expression, such as a string or a symbol, not
  between them, that S-expression is considered to follow the point.&quot;</span>
  <span class='i'>(interactive &quot;P&quot;)</span>
  <span class='i'>(save-excursion
    (cond ((paredit-in-string-p)
           (goto-char (car (paredit-string-start+end-points))))
          ((paredit-in-char-p)
           (backward-sexp))
          ((paredit-in-comment-p)
           (error &quot;No S-expression to raise in comment.&quot;)))
    ;; Select the S-expressions we want to raise in a buffer substring.
    (let* ((n (prefix-numeric-value argument))
           (bound (scan-sexps (point) n))
           (sexps
            (if (&lt; n 0)
                (buffer-substring bound (paredit-point-at-sexp-end))
                (buffer-substring (paredit-point-at-sexp-start) bound))))
      ;; Move up to the list we&#39;re raising those S-expressions out of and
      ;; delete it.
      (backward-up-list)
      (delete-region (point) (scan-sexps (point) 1))
      (let* ((indent-start (point))
             (indent-end (save-excursion (insert sexps) (point))))
        (indent-region indent-start indent-end))))</span>)

<span class='i'>(defun paredit-convolute-sexp (&optional n)
  &quot;Convolute S-expressions.
Save the S-expressions preceding point and delete them.
Splice the S-expressions following point.
Wrap the enclosing list in a new list prefixed by the saved text.
With a prefix argument N, move up N lists before wrapping.&quot;
  (interactive &quot;p&quot;)
  (paredit-lose-if-not-in-sexp &#39;paredit-convolute-sexp)
  (let (open close)                     ;++ Is this a good idea?
    (let ((prefix
           (let ((end (point)))
             (paredit-ignore-sexp-errors
               (while (not (bobp)) (backward-sexp)))
             (prog1 (buffer-substring (point) end)
               (backward-up-list)
               (save-excursion (forward-sexp)
                               (setq close (char-before))
                               (backward-delete-char 1))
               (setq open (char-after))
               (delete-region (point) end)))))
      (backward-up-list n)
      (paredit-insert-pair 1 open close &#39;goto-char)
      (insert prefix)
      (backward-up-list)
      (paredit-ignore-sexp-errors (indent-sexp)))))</span>

<span class='i'>(defun paredit-splice-string (argument)
  (let ((original-point (point))
        (start+end (paredit-string-start+end-points)))
    (let ((start (car start+end))
          (end (cdr start+end)))
      ;; START and END both lie before the respective quote
      ;; characters, which we want to delete; thus we increment START
      ;; by one to extract the string, and we increment END by one to
      ;; delete the string.
      (let* ((escaped-string
              (cond ((not (consp argument))
                     (buffer-substring (1+ start) end))
                    ((= 4 (car argument))
                     (buffer-substring original-point end))
                    (t
                     (buffer-substring (1+ start) original-point))))
             (unescaped-string
              (paredit-unescape-string escaped-string)))
        (if (not unescaped-string)
            (error &quot;Unspliceable string.&quot;)
          (save-excursion
            (goto-char start)
            (delete-region start (1+ end))
            (insert unescaped-string))
          (if (not (and (consp argument)
                        (= 4 (car argument))))
              (goto-char (- original-point 1))))))))</span>

<span class='i'>(defun paredit-unescape-string (string)
  (with-temp-buffer
    (insert string)
    (goto-char (point-min))
    (while (and (not (eobp))
                ;; nil -&gt; no bound; t -&gt; no errors.
                (search-forward &quot;\\&quot; nil t))
      (delete-char -1)
      (forward-char))
    (condition-case condition
        (progn (check-parens) (buffer-string))
      (error nil))))</span>

<a id='4884' tid='4883' class='u'>;;;; Slurpage & Barfage
</a>
(<a id='3098' tid='3097' class='u'>defun</a> <a id='3100' tid='3099' class='u'>paredit-forward-slurp-sexp</a> ()
  <a id='3102' tid='3101' class='u'>&quot;Add the S-expression following the current list into that list
  by moving the closing delimiter.
Automatically reindent the newly slurped S-expression with respect to
  its new enclosing form.
If in a string, move the opening double-quote forward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='3104' tid='3103' class='u'>interactive</a>)
  <span class='i'>(save-excursion
    (cond ((or (paredit-in-comment-p)
               (paredit-in-char-p))
           (error &quot;Invalid context for slurping S-expressions.&quot;))
          ((paredit-in-string-p)
           (paredit-forward-slurp-into-string))
          (t
           (paredit-forward-slurp-into-list))))</span>)

(<a id='3048' tid='3047' class='u'>defun</a> <a id='3050' tid='3049' class='u'>paredit-forward-slurp-into-list</a> ()
  (<a id='3052' tid='3051' class='u'>up-list</a>)                             <a id='3054' tid='3053' class='u'>; Up to the end of the list to
</a>  (<a id='1246' tid='1245' class='m'>let</a> ((<a id='1248' tid='1247' class='m'>close</a> (<a id='1250' tid='1249' class='m'>char-before</a>)))          <a id='1252' tid='1251' class='m'>;   save and delete the closing
</a>    (<a id='1254' tid='1253' class='m'>backward-delete-char</a> <a id='1256' tid='1255' class='m'>1</a>)            <a id='1258' tid='1257' class='m'>;   delimiter.
</a>    (<a id='1260' tid='1259' class='m'>catch</a> <a id='1262' tid='1261' class='m'>&#39;</a><a id='1264' tid='1263' class='m'>return</a>                      <a id='1266' tid='1265' class='m'>; Go to the end of the desired
</a>      (<a id='1268' tid='1267' class='m'>while</a> <a id='1270' tid='1269' class='m'>t</a>                          <a id='1272' tid='1271' class='m'>;   S-expression, going up a
</a>        (<span class='i'>paredit-handle-sexp-errors</span>     <span class='i'>;   list if it&#39;s not in this,
</span>            (<a id='1274' tid='1273' class='m'>progn</a> (<a id='1276' tid='1275' class='m'>paredit-forward-and-indent</a>)
                   (<a id='1278' tid='1277' class='m'>throw</a> <a id='1280' tid='1279' class='m'>&#39;</a><a id='1282' tid='1281' class='m'>return</a> <a id='1284' tid='1283' class='m'>nil</a>))
          <span class='i'>(up-list)</span>
          <span class='i'>(setq close                   ; adjusting for mixed
                (prog1 (char-before)    ;   delimiters as necessary,
                  (backward-delete-char 1)
                  (insert close)))</span>)))
    (<a id='1286' tid='1285' class='m'>insert</a> <a id='1288' tid='1287' class='m'>close</a>)))                    <a id='4886' tid='4885' class='u'>; to insert that delimiter.
</a>
(<a id='3056' tid='3055' class='u'>defun</a> <a id='3058' tid='3057' class='u'>paredit-forward-slurp-into-string</a> ()
  (<a id='3060' tid='3059' class='u'>goto-char</a> (<a id='3062' tid='3061' class='u'>1+</a> (<a id='3064' tid='3063' class='u'>cdr</a> (<a id='3066' tid='3065' class='u'>paredit-string-start+end-points</a>))))
  <a id='3068' tid='3067' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='3070' tid='3069' class='u'>;; buffer&#39;s contents.
</a>  (<a id='3072' tid='3071' class='u'>save-excursion</a> (<a id='3074' tid='3073' class='u'>forward-sexp</a>))
  (<a id='3076' tid='3075' class='u'>let</a> ((<a id='3078' tid='3077' class='u'>close</a> (<a id='3080' tid='3079' class='u'>char-before</a>)))
    (<a id='3082' tid='3081' class='u'>backward-delete-char</a> <a id='3084' tid='3083' class='u'>1</a>)
    (<a id='3086' tid='3085' class='u'>paredit-forward-for-quote</a> (<a id='3088' tid='3087' class='u'>save-excursion</a> (<a id='3090' tid='3089' class='u'>forward-sexp</a>) (<a id='3092' tid='3091' class='u'>point</a>)))
    (<a id='3094' tid='3093' class='u'>insert</a> <a id='3096' tid='3095' class='u'>close</a>)))

(<a id='2438' tid='2437' class='u'>defun</a> <a id='2440' tid='2439' class='u'>paredit-forward-barf-sexp</a> ()
  <a id='2442' tid='2441' class='u'>&quot;Remove the last S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the newly barfed S-expression with respect to
  its new enclosing form.&quot;</a>
  (<a id='2444' tid='2443' class='u'>interactive</a>)
  <span class='i'>(paredit-lose-if-not-in-sexp &#39;paredit-forward-barf-sexp)</span>
  (<a id='2446' tid='2445' class='u'>save-excursion</a>
    (<a id='2448' tid='2447' class='u'>up-list</a>)                           <a id='2450' tid='2449' class='u'>; Up to the end of the list to
</a>    (<a id='2452' tid='2451' class='u'>let</a> ((<a id='2454' tid='2453' class='u'>close</a> (<a id='2456' tid='2455' class='u'>char-before</a>)))        <a id='2458' tid='2457' class='u'>;   save and delete the closing
</a>      (<a id='2460' tid='2459' class='u'>backward-delete-char</a> <a id='2462' tid='2461' class='u'>1</a>)          <a id='2464' tid='2463' class='u'>;   delimiter.
</a>      (<a id='2466' tid='2465' class='u'>paredit-ignore-sexp-errors</a>       <a id='2468' tid='2467' class='u'>; Go back to where we want to
</a>        (<a id='2470' tid='2469' class='u'>backward-sexp</a>))                <a id='2472' tid='2471' class='u'>;   insert the delimiter.
</a>      (<a id='2474' tid='2473' class='u'>paredit-skip-whitespace</a> <a id='2476' tid='2475' class='u'>nil</a>)     <a id='2478' tid='2477' class='u'>; Skip leading whitespace.
</a>      (<a id='2480' tid='2479' class='u'>cond</a> ((<a id='2482' tid='2481' class='u'>bobp</a>)
             (<a id='2484' tid='2483' class='u'>error</a> <a id='2486' tid='2485' class='u'>&quot;Barfing all subexpressions with no open-paren?&quot;</a>))
            ((<a id='2488' tid='2487' class='u'>paredit-in-comment-p</a>)     <a id='2490' tid='2489' class='u'>; Don&#39;t put the close-paren in
</a>             (<a id='2492' tid='2491' class='u'>newline-and-indent</a>)))     <a id='2494' tid='2493' class='u'>;   a comment.
</a>      (<a id='2496' tid='2495' class='u'>insert</a> <a id='2498' tid='2497' class='u'>close</a>))
    <a id='2500' tid='2499' class='u'>;; Reindent all of the newly barfed S-expressions.
</a>    (<a id='2502' tid='2501' class='u'>paredit-forward-and-indent</a>)))

(<a id='2152' tid='2151' class='u'>defun</a> <a id='2154' tid='2153' class='u'>paredit-backward-slurp-sexp</a> ()
  <a id='2156' tid='2155' class='u'>&quot;Add the S-expression preceding the current list into that list
  by moving the closing delimiter.
Automatically reindent the whole form into which new S-expression was
  slurped.
If in a string, move the opening double-quote backward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='2158' tid='2157' class='u'>interactive</a>)
  <span class='i'>(save-excursion
    (cond ((or (paredit-in-comment-p)
               (paredit-in-char-p))
           (error &quot;Invalid context for slurping S-expressions.&quot;))
          ((paredit-in-string-p)
           (paredit-backward-slurp-into-string))
          (t
           (paredit-backward-slurp-into-list))))</span>)

(<a id='2122' tid='2121' class='u'>defun</a> <a id='2124' tid='2123' class='u'>paredit-backward-slurp-into-list</a> ()
  (<a id='2126' tid='2125' class='u'>backward-up-list</a>)
  (<a id='1290' tid='1289' class='m'>let</a> ((<a id='1292' tid='1291' class='m'>open</a> (<a id='1294' tid='1293' class='m'>char-after</a>)))
    (<a id='1296' tid='1295' class='m'>delete-char</a> <a id='1298' tid='1297' class='m'>1</a>)
    (<a id='1300' tid='1299' class='m'>catch</a> <a id='1302' tid='1301' class='m'>&#39;</a><a id='1304' tid='1303' class='m'>return</a>
      (<a id='1306' tid='1305' class='m'>while</a> <a id='1308' tid='1307' class='m'>t</a>
        (<span class='i'>paredit-handle-sexp-errors</span>
            (<a id='1310' tid='1309' class='m'>progn</a> (<a id='1312' tid='1311' class='m'>backward-sexp</a>) (<a id='1314' tid='1313' class='m'>throw</a> <a id='1316' tid='1315' class='m'>&#39;</a><a id='1318' tid='1317' class='m'>return</a> <a id='1320' tid='1319' class='m'>nil</a>))
          <span class='i'>(backward-up-list)</span>
          <span class='i'>(setq open
                (prog1 (char-after)
                  (save-excursion (insert open) (delete-char 1))))</span>)))
    (<a id='1322' tid='1321' class='m'>insert</a> <a id='1324' tid='1323' class='m'>open</a>))
  <span class='i'>;; Reindent the line at the beginning of wherever we inserted the
</span>  <span class='i'>;; opening delimiter, and then indent the whole S-expression.
</span>  (<a id='2128' tid='2127' class='u'>backward-up-list</a>)
  (<a id='2130' tid='2129' class='u'>lisp-indent-line</a>)
  (<a id='2132' tid='2131' class='u'>indent-sexp</a>))

(<a id='2134' tid='2133' class='u'>defun</a> <a id='2136' tid='2135' class='u'>paredit-backward-slurp-into-string</a> ()
  (<a id='2138' tid='2137' class='u'>goto-char</a> (<a id='2140' tid='2139' class='u'>car</a> (<a id='2142' tid='2141' class='u'>paredit-string-start+end-points</a>)))
  <a id='2144' tid='2143' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='2146' tid='2145' class='u'>;; buffer&#39;s contents.
</a>  (<a id='2148' tid='2147' class='u'>save-excursion</a> (<a id='2150' tid='2149' class='u'>backward-sexp</a>))
  <span class='i'>(let ((open (char-after))
        (target (point)))
    (delete-char 1)
    (backward-sexp)
    (insert open)
    (paredit-forward-for-quote target))</span>)

(<a id='1800' tid='1799' class='u'>defun</a> <a id='1802' tid='1801' class='u'>paredit-backward-barf-sexp</a> ()
  <a id='1804' tid='1803' class='u'>&quot;Remove the first S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the barfed S-expression and the form from which
  it was barfed.&quot;</a>
  (<a id='1806' tid='1805' class='u'>interactive</a>)
  <span class='i'>(paredit-lose-if-not-in-sexp &#39;paredit-backward-barf-sexp)</span>
  (<a id='1808' tid='1807' class='u'>save-excursion</a>
    (<a id='1810' tid='1809' class='u'>backward-up-list</a>)
    (<a id='1812' tid='1811' class='u'>let</a> ((<a id='1814' tid='1813' class='u'>open</a> (<a id='1816' tid='1815' class='u'>char-after</a>)))
      (<a id='1818' tid='1817' class='u'>delete-char</a> <a id='1820' tid='1819' class='u'>1</a>)
      (<a id='1822' tid='1821' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='1824' tid='1823' class='u'>paredit-forward-and-indent</a>))
      (<a id='1826' tid='1825' class='u'>while</a> (<a id='1828' tid='1827' class='u'>progn</a> (<a id='1830' tid='1829' class='u'>paredit-skip-whitespace</a> <a id='1832' tid='1831' class='u'>t</a>)
                    (<a id='1834' tid='1833' class='u'>eq</a> (<a id='1836' tid='1835' class='u'>char-after</a>) <a id='1838' tid='1837' class='u'>?\;</a> ))
        (<a id='1840' tid='1839' class='u'>forward-line</a> <a id='1842' tid='1841' class='u'>1</a>))
      (<a id='1844' tid='1843' class='u'>if</a> (<a id='1846' tid='1845' class='u'>eobp</a>)
          (<a id='1848' tid='1847' class='u'>error</a> <a id='1850' tid='1849' class='u'>&quot;Barfing all subexpressions with no close-paren?&quot;</a>))
      <a id='1852' tid='1851' class='u'>;** Don&#39;t use `insert&#39; here.  Consider, e.g., barfing from
</a>      <a id='1854' tid='1853' class='u'>;**   (foo|)
</a>      <a id='1856' tid='1855' class='u'>;** and how `save-excursion&#39; works.
</a>      (<a id='1858' tid='1857' class='u'>insert-before-markers</a> <a id='1860' tid='1859' class='u'>open</a>))
    (<a id='1862' tid='1861' class='u'>backward-up-list</a>)
    (<a id='1864' tid='1863' class='u'>lisp-indent-line</a>)
    (<a id='1866' tid='1865' class='u'>indent-sexp</a>)))

<a id='4888' tid='4887' class='u'>;;;; Splitting & Joining
</a>
(<a id='4560' tid='4559' class='u'>defun</a> <a id='4562' tid='4561' class='u'>paredit-split-sexp</a> ()
  <a id='4564' tid='4563' class='u'>&quot;Split the list or string the point is on into two.&quot;</a>
  (<a id='4566' tid='4565' class='u'>interactive</a>)
  (<span class='i'>cond</span> ((<a id='1326' tid='1325' class='m'>paredit-in-string-p</a>)
         (<a id='1328' tid='1327' class='m'>insert</a> <a id='1330' tid='1329' class='m'>&quot;\&quot;&quot;</a>)
         (<a id='1332' tid='1331' class='m'>save-excursion</a> (<a id='1334' tid='1333' class='m'>insert</a> <a id='1336' tid='1335' class='m'>&quot; \&quot;&quot;</a>)))
        <span class='i'>((or (paredit-in-comment-p)
             (paredit-in-char-p))
         (error &quot;Invalid context for splitting S-expression.&quot;))</span>
        (<a id='574' tid='573' class='m'>t</a> (<a id='576' tid='575' class='m'>let</a> ((<a id='578' tid='577' class='m'>open</a>  (<a id='580' tid='579' class='m'>save-excursion</a> (<a id='582' tid='581' class='m'>backward-up-list</a>)
                                        (<a id='584' tid='583' class='m'>char-after</a>)))
                 (<a id='586' tid='585' class='m'>close</a> (<a id='588' tid='587' class='m'>save-excursion</a> (<a id='590' tid='589' class='m'>up-list</a>)
                                        (<a id='592' tid='591' class='m'>char-before</a>))))
             (<a id='594' tid='593' class='m'>delete-horizontal-space</a>)
             (<a id='596' tid='595' class='m'>insert</a> <a id='598' tid='597' class='m'>close</a>)
             (<a id='600' tid='599' class='m'>save-excursion</a> (<a id='602' tid='601' class='m'>insert</a> <a id='604' tid='603' class='m'>?\ </a>)
                             (<a id='606' tid='605' class='m'>insert</a> <a id='608' tid='607' class='m'>open</a>)
                             (<a id='610' tid='609' class='m'>backward-char</a>)
                             (<a id='612' tid='611' class='m'>indent-sexp</a>))))))

(<a id='3648' tid='3647' class='u'>defun</a> <a id='3650' tid='3649' class='u'>paredit-join-sexps</a> ()
  <a id='3652' tid='3651' class='u'>&quot;Join the S-expressions adjacent on either side of the point.
Both must be lists, strings, or atoms; error if there is a mismatch.&quot;</a>
  (<a id='3654' tid='3653' class='u'>interactive</a>)
  <a id='3656' tid='3655' class='u'>;++ How ought this to handle comments intervening symbols or strings?
</a>  (<a id='1338' tid='1337' class='m'>save-excursion</a>
    (<span class='i'>if</span> <span class='i'>(or (paredit-in-comment-p)
            (paredit-in-string-p)
            (paredit-in-char-p))</span>
        <span class='i'>(error &quot;Invalid context for joining S-expressions.&quot;)</span>
      (<span class='i'>let</span> <span class='i'>((left-point  (paredit-point-at-sexp-end))
            (right-point (paredit-point-at-sexp-start)))</span>
        (<a id='1340' tid='1339' class='m'>let</a> ((<a id='1342' tid='1341' class='m'>left-char</a> (<a id='1344' tid='1343' class='m'>char-before</a> <a id='1346' tid='1345' class='m'>left-point</a>))
              (<a id='1348' tid='1347' class='m'>right-char</a> (<a id='1350' tid='1349' class='m'>char-after</a> <a id='1352' tid='1351' class='m'>right-point</a>)))
          (<a id='1354' tid='1353' class='m'>let</a> ((<a id='1356' tid='1355' class='m'>left-syntax</a> (<a id='1358' tid='1357' class='m'>char-syntax</a> <a id='1360' tid='1359' class='m'>left-char</a>))
                (<a id='1362' tid='1361' class='m'>right-syntax</a> (<a id='1364' tid='1363' class='m'>char-syntax</a> <a id='1366' tid='1365' class='m'>right-char</a>)))
            (<a id='1368' tid='1367' class='m'>cond</a> ((<a id='1370' tid='1369' class='m'>&gt;=</a> <a id='1372' tid='1371' class='m'>left-point</a> <a id='1374' tid='1373' class='m'>right-point</a>)
                   (<a id='1376' tid='1375' class='m'>error</a> <a id='1378' tid='1377' class='m'>&quot;Can&#39;t join a datum with itself.&quot;</a>))
                  ((<a id='1380' tid='1379' class='m'>and</a> (<a id='1382' tid='1381' class='m'>eq</a> <a id='1384' tid='1383' class='m'>left-syntax</a>  <a id='1386' tid='1385' class='m'>?\)</a> )
                        (<a id='1388' tid='1387' class='m'>eq</a> <a id='1390' tid='1389' class='m'>right-syntax</a> <a id='1392' tid='1391' class='m'>?\(</a> )
                        (<a id='1394' tid='1393' class='m'>eq</a> <a id='1396' tid='1395' class='m'>left-char</a> (<a id='1398' tid='1397' class='m'>matching-paren</a> <a id='1400' tid='1399' class='m'>right-char</a>))
                        (<a id='1402' tid='1401' class='m'>eq</a> <a id='1404' tid='1403' class='m'>right-char</a> (<a id='1406' tid='1405' class='m'>matching-paren</a> <a id='1408' tid='1407' class='m'>left-char</a>)))
                   <a id='1410' tid='1409' class='m'>;; Leave intermediate formatting alone.
</a>                   (<a id='1412' tid='1411' class='m'>goto-char</a> <a id='1414' tid='1413' class='m'>right-point</a>)
                   (<a id='1416' tid='1415' class='m'>delete-char</a> <a id='1418' tid='1417' class='m'>1</a>)
                   (<a id='1420' tid='1419' class='m'>goto-char</a> <a id='1422' tid='1421' class='m'>left-point</a>)
                   (<a id='1424' tid='1423' class='m'>backward-delete-char</a> <a id='1426' tid='1425' class='m'>1</a>)
                   (<a id='1428' tid='1427' class='m'>backward-up-list</a>)
                   (<a id='1430' tid='1429' class='m'>indent-sexp</a>))
                  ((<a id='1432' tid='1431' class='m'>and</a> (<a id='1434' tid='1433' class='m'>eq</a> <a id='1436' tid='1435' class='m'>left-syntax</a>  <a id='1438' tid='1437' class='m'>?\&quot;</a> )
                        (<a id='1440' tid='1439' class='m'>eq</a> <a id='1442' tid='1441' class='m'>right-syntax</a> <a id='1444' tid='1443' class='m'>?\&quot;</a> ))
                   <a id='1446' tid='1445' class='m'>;; Delete any intermediate formatting.
</a>                   (<a id='1448' tid='1447' class='m'>delete-region</a> (<a id='1450' tid='1449' class='m'>1-</a> <a id='1452' tid='1451' class='m'>left-point</a>)
                                  (<a id='1454' tid='1453' class='m'>1+</a> <a id='1456' tid='1455' class='m'>right-point</a>)))
                  ((<a id='1458' tid='1457' class='m'>and</a> (<a id='1460' tid='1459' class='m'>memq</a> <a id='1462' tid='1461' class='m'>left-syntax</a>  <a id='1464' tid='1463' class='m'>&#39;</a>(<a id='1466' tid='1465' class='m'>?w</a> <a id='1468' tid='1467' class='m'>?_</a>)) <a id='1470' tid='1469' class='m'>; Word or symbol
</a>                        (<a id='1472' tid='1471' class='m'>memq</a> <a id='1474' tid='1473' class='m'>right-syntax</a> <a id='1476' tid='1475' class='m'>&#39;</a>(<a id='1478' tid='1477' class='m'>?w</a> <a id='1480' tid='1479' class='m'>?_</a>)))
                   (<a id='1482' tid='1481' class='m'>delete-region</a> <a id='1484' tid='1483' class='m'>left-point</a> <a id='1486' tid='1485' class='m'>right-point</a>))
                  (<a id='1488' tid='1487' class='m'>t</a>
                   (<a id='1490' tid='1489' class='m'>error</a> <a id='1492' tid='1491' class='m'>&quot;Mismatched S-expressions to join.&quot;</a>)))))))))

<span class='i'>;;;; Variations on the Lurid Theme
</span>
<span class='i'>;;; I haven&#39;t the imagination to concoct clever names for these.
</span>
<span class='i'>(defun paredit-add-to-previous-list ()
  &quot;Add the S-expression following point to the list preceding point.&quot;
  (interactive)
  (paredit-lose-if-not-in-sexp &#39;paredit-add-to-previous-list)
  (save-excursion
    (backward-down-list)
    (paredit-forward-slurp-sexp)))</span>

<span class='i'>(defun paredit-add-to-next-list ()
  &quot;Add the S-expression preceding point to the list following point.
If no S-expression precedes point, move up the tree until one does.&quot;
  (interactive)
  (paredit-lose-if-not-in-sexp &#39;paredit-add-to-next-list)
  (save-excursion
    (down-list)
    (paredit-backward-slurp-sexp)))</span>

<span class='i'>(defun paredit-join-with-previous-list ()
  &quot;Join the list the point is on with the previous list in the buffer.&quot;
  (interactive)
  (paredit-lose-if-not-in-sexp &#39;paredit-join-with-previous-list)
  (save-excursion
    (while (paredit-handle-sexp-errors (save-excursion (backward-sexp) nil)
             (backward-up-list)
             t))
    (paredit-join-sexps)))</span>

<span class='i'>(defun paredit-join-with-next-list ()
  &quot;Join the list the point is on with the next list in the buffer.&quot;
  (interactive)
  (paredit-lose-if-not-in-sexp &#39;paredit-join-with-next-list)
  (save-excursion
    (while (paredit-handle-sexp-errors (save-excursion (forward-sexp) nil)
             (up-list)
             t))
    (paredit-join-sexps)))</span>

<span class='i'>;;;; Utilities
</span>
(<a id='3262' tid='3261' class='u'>defun</a> <a id='3264' tid='3263' class='u'>paredit-in-string-escape-p</a> ()
  <a id='3266' tid='3265' class='u'>&quot;True if the point is on a character escape of a string.
This is true only if the character is preceded by an odd number of
  backslashes.
This assumes that `paredit-in-string-p&#39; has already returned true.&quot;</a>
  (<a id='3268' tid='3267' class='u'>let</a> ((<a id='3270' tid='3269' class='u'>oddp</a> <a id='3272' tid='3271' class='u'>nil</a>))
    (<a id='3274' tid='3273' class='u'>save-excursion</a>
      (<a id='3276' tid='3275' class='u'>while</a> (<a id='3278' tid='3277' class='u'>eq</a> (<a id='3280' tid='3279' class='u'>char-before</a>) <a id='3282' tid='3281' class='u'>?\\</a> )
        (<a id='3284' tid='3283' class='u'>setq</a> <a id='3286' tid='3285' class='u'>oddp</a> (<a id='3288' tid='3287' class='u'>not</a> <a id='3290' tid='3289' class='u'>oddp</a>))
        (<a id='3292' tid='3291' class='u'>backward-char</a>)))
    <a id='3294' tid='3293' class='u'>oddp</a>))

(<a id='3228' tid='3227' class='u'>defun</a> <a id='3230' tid='3229' class='u'>paredit-in-char-p</a> <span class='i'>(&optional argument)</span>
  <a id='3232' tid='3231' class='u'>&quot;True if the point is immediately after a character literal.
A preceding escape character, not preceded by another escape character,
  is considered a character literal prefix.  (This works for elisp,
  Common Lisp, and Scheme.)
Assumes that `paredit-in-string-p&#39; is false, so that it need not handle
  long sequences of preceding backslashes in string escapes.  (This
  assumes some other leading character token -- ? in elisp, # in Scheme
  and Common Lisp.)&quot;</a>
  <span class='i'>(let ((argument (or argument (point))))
    (and (eq (char-before argument) ?\\ )
         (not (eq (char-before (1- argument)) ?\\ ))))</span>)

<span class='i'>(defun paredit-indent-sexps ()
  &quot;If in a list, indent all following S-expressions in the list.&quot;
  (let ((start (point))
        (end (paredit-handle-sexp-errors (progn (up-list) (point)) nil)))
    (if end
        (indent-region start end))))</span>

(<a id='2434' tid='2433' class='u'>defun</a> <a id='2436' tid='2435' class='u'>paredit-forward-and-indent</a> ()
  <span class='i'>&quot;Move forward an S-expression, indenting it with `indent-region&#39;.&quot;</span>
  <span class='i'>(let ((start (point)))
    (forward-sexp)
    (indent-region start (point)))</span>)

(<a id='4446' tid='4445' class='u'>defun</a> <a id='4448' tid='4447' class='u'>paredit-skip-whitespace</a> (<a id='4450' tid='4449' class='u'>trailing-p</a> <a id='4452' tid='4451' class='u'>&optional</a> <a id='4454' tid='4453' class='u'>limit</a>)
  <a id='4456' tid='4455' class='u'>&quot;Skip past any whitespace, or until the point LIMIT is reached.
If TRAILING-P is nil, skip leading whitespace; otherwise, skip trailing
  whitespace.&quot;</a>
  (<a id='4458' tid='4457' class='u'>funcall</a> (<a id='4460' tid='4459' class='u'>if</a> <a id='4462' tid='4461' class='u'>trailing-p</a> <a id='4464' tid='4463' class='u'>&#39;</a><a id='4466' tid='4465' class='u'>skip-chars-forward</a> <a id='4468' tid='4467' class='u'>&#39;</a><a id='4470' tid='4469' class='u'>skip-chars-backward</a>)
           <a id='4472' tid='4471' class='u'>&quot; \t\n&quot;</a>  <a id='4474' tid='4473' class='u'>; This should skip using the syntax table, but LF
</a>           <a id='4476' tid='4475' class='u'>limit</a>))    <span class='i'>; is a comment end, not newline, in Lisp mode.
</span>
(<a id='4890' tid='4889' class='u'>defalias</a> <a id='4892' tid='4891' class='u'>&#39;</a><a id='4894' tid='4893' class='u'>paredit-region-active-p</a>
  (<a id='4896' tid='4895' class='u'>xcond</a> ((<a id='4898' tid='4897' class='u'>paredit-xemacs-p</a>) <a id='4900' tid='4899' class='u'>&#39;</a><a id='4902' tid='4901' class='u'>region-active-p</a>)
         ((<a id='4904' tid='4903' class='u'>paredit-gnu-emacs-p</a>)
          (<a id='4906' tid='4905' class='u'>lambda</a> ()
            (<a id='4908' tid='4907' class='u'>and</a> <a id='4910' tid='4909' class='u'>mark-active</a> <a id='4912' tid='4911' class='u'>transient-mark-mode</a>)))))

<span class='i'>(defun paredit-hack-kill-region (start end)
  &quot;Kill the region between START and END.
Do not append to any current kill, and
 do not let the next kill append to this one.&quot;
  (interactive &quot;r&quot;)                     ;Eh, why not?
  ;; KILL-REGION sets THIS-COMMAND to tell the next kill that the last
  ;; command was a kill.  It also checks LAST-COMMAND to see whether it
  ;; should append.  If we bind these locally, any modifications to
  ;; THIS-COMMAND will be masked, and it will not see LAST-COMMAND to
  ;; indicate that it should append.
  (let ((this-command nil)
        (last-command nil))
    (kill-region start end)))</span>

<a id='4914' tid='4913' class='u'>;;;;; S-expression Parsing Utilities
</a>
<a id='4916' tid='4915' class='u'>;++ These routines redundantly traverse S-expressions a great deal.
</a><a id='4918' tid='4917' class='u'>;++ If performance issues arise, this whole section will probably have
</a><a id='4920' tid='4919' class='u'>;++ to be refactored to preserve the state longer, like paredit.scm
</a><a id='4922' tid='4921' class='u'>;++ does, rather than to traverse the definition N times for every key
</a><a id='4924' tid='4923' class='u'>;++ stroke as it presently does.
</a>
(<a id='2222' tid='2221' class='u'>defun</a> <a id='2224' tid='2223' class='u'>paredit-current-parse-state</a> ()
  <a id='2226' tid='2225' class='u'>&quot;Return parse state of point from beginning of defun.&quot;</a>
  (<a id='2228' tid='2227' class='u'>let</a> ((<a id='2230' tid='2229' class='u'>point</a> (<a id='2232' tid='2231' class='u'>point</a>)))
    (<a id='2234' tid='2233' class='u'>beginning-of-defun</a>)
    <a id='2236' tid='2235' class='u'>;; Calling PARSE-PARTIAL-SEXP will advance the point to its second
</a>    <a id='2238' tid='2237' class='u'>;; argument (unless parsing stops due to an error, but we assume it
</a>    <a id='2240' tid='2239' class='u'>;; won&#39;t in paredit-mode).
</a>    (<a id='2242' tid='2241' class='u'>parse-partial-sexp</a> (<a id='2244' tid='2243' class='u'>point</a>) <a id='2246' tid='2245' class='u'>point</a>)))

(<a id='3296' tid='3295' class='u'>defun</a> <a id='3298' tid='3297' class='u'>paredit-in-string-p</a> (<a id='3300' tid='3299' class='u'>&optional</a> <a id='3302' tid='3301' class='u'>state</a>)
  <a id='3304' tid='3303' class='u'>&quot;True if the parse state is within a double-quote-delimited string.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='3306' tid='3305' class='u'>;; 3. non-nil if inside a string (the terminator character, really)
</a>  (<a id='3308' tid='3307' class='u'>and</a> (<a id='3310' tid='3309' class='u'>nth</a> <a id='3312' tid='3311' class='u'>3</a> (<a id='3314' tid='3313' class='u'>or</a> <a id='3316' tid='3315' class='u'>state</a> (<a id='3318' tid='3317' class='u'>paredit-current-parse-state</a>)))
       <a id='3320' tid='3319' class='u'>t</a>))

(<a id='4568' tid='4567' class='u'>defun</a> <a id='4570' tid='4569' class='u'>paredit-string-start+end-points</a> (<a id='4572' tid='4571' class='u'>&optional</a> <a id='4574' tid='4573' class='u'>state</a>)
  <a id='4576' tid='4575' class='u'>&quot;Return a cons of the points of open and close quotes of the string.
The string is determined from the parse state STATE, or the parse state
  from the beginning of the defun to the point.
This assumes that `paredit-in-string-p&#39; has already returned true, i.e.
  that the point is already within a string.&quot;</a>
  (<a id='4578' tid='4577' class='u'>save-excursion</a>
    <a id='4580' tid='4579' class='u'>;; 8. character address of start of comment or string; nil if not
</a>    <a id='4582' tid='4581' class='u'>;;    in one
</a>    (<a id='4584' tid='4583' class='u'>let</a> ((<a id='4586' tid='4585' class='u'>start</a> (<a id='4588' tid='4587' class='u'>nth</a> <a id='4590' tid='4589' class='u'>8</a> (<a id='4592' tid='4591' class='u'>or</a> <a id='4594' tid='4593' class='u'>state</a> (<a id='4596' tid='4595' class='u'>paredit-current-parse-state</a>)))))
      (<a id='4598' tid='4597' class='u'>goto-char</a> <a id='4600' tid='4599' class='u'>start</a>)
      (<a id='4602' tid='4601' class='u'>forward-sexp</a> <a id='4604' tid='4603' class='u'>1</a>)
      (<a id='4606' tid='4605' class='u'>cons</a> <a id='4608' tid='4607' class='u'>start</a> (<a id='4610' tid='4609' class='u'>1-</a> (<a id='4612' tid='4611' class='u'>point</a>))))))

(<a id='3234' tid='3233' class='u'>defun</a> <a id='3236' tid='3235' class='u'>paredit-in-comment-p</a> (<a id='3238' tid='3237' class='u'>&optional</a> <a id='3240' tid='3239' class='u'>state</a>)
  <a id='3242' tid='3241' class='u'>&quot;True if parse state STATE is within a comment.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='3244' tid='3243' class='u'>;; 4. nil if outside a comment, t if inside a non-nestable comment,
</a>  <a id='3246' tid='3245' class='u'>;;    else an integer (the current comment nesting)
</a>  (<a id='3248' tid='3247' class='u'>and</a> (<a id='3250' tid='3249' class='u'>nth</a> <a id='3252' tid='3251' class='u'>4</a> (<a id='3254' tid='3253' class='u'>or</a> <a id='3256' tid='3255' class='u'>state</a> (<a id='3258' tid='3257' class='u'>paredit-current-parse-state</a>)))
       <a id='3260' tid='3259' class='u'>t</a>))

(<a id='4220' tid='4219' class='u'>defun</a> <a id='4222' tid='4221' class='u'>paredit-point-at-sexp-boundary</a> (<a id='4224' tid='4223' class='u'>n</a>)
  (<a id='4226' tid='4225' class='u'>cond</a> ((<a id='4228' tid='4227' class='u'>&lt;</a> <a id='4230' tid='4229' class='u'>n</a> <a id='4232' tid='4231' class='u'>0</a>) (<a id='4234' tid='4233' class='u'>paredit-point-at-sexp-start</a>))
        ((<a id='4236' tid='4235' class='u'>=</a> <a id='4238' tid='4237' class='u'>n</a> <a id='4240' tid='4239' class='u'>0</a>) (<a id='4242' tid='4241' class='u'>point</a>))
        ((<a id='4244' tid='4243' class='u'>&gt;</a> <a id='4246' tid='4245' class='u'>n</a> <a id='4248' tid='4247' class='u'>0</a>) (<a id='4250' tid='4249' class='u'>paredit-point-at-sexp-end</a>))))

(<a id='4256' tid='4255' class='u'>defun</a> <a id='4258' tid='4257' class='u'>paredit-point-at-sexp-start</a> ()
  <span class='i'>(save-excursion
    (forward-sexp)
    (backward-sexp)
    (point))</span>)

(<a id='4252' tid='4251' class='u'>defun</a> <a id='4254' tid='4253' class='u'>paredit-point-at-sexp-end</a> ()
  <span class='i'>(save-excursion
    (backward-sexp)
    (forward-sexp)
    (point))</span>)

<span class='i'>(defun paredit-lose-if-not-in-sexp (command)
  (if (or (paredit-in-string-p)
          (paredit-in-comment-p)
          (paredit-in-char-p))
      (error &quot;Invalid context for command `%s&#39;.&quot; command)))</span>

<span class='i'>(defun paredit-check-region (start end)
  (save-restriction
    (narrow-to-region start end)
    (if (fboundp &#39;check-parens)
        (check-parens)
        (save-excursion
          (goto-char (point-min))
          (while (not (eobp))
            (forward-sexp))))))</span>

<span class='i'>(defun paredit-region-ok-p (start end)
  (paredit-handle-sexp-errors
      (progn
        (save-restriction
          (narrow-to-region start end)
          ;; Can&#39;t use `check-parens&#39; here -- it signals the wrong kind
          ;; of errors.
          (save-excursion
            (goto-char (point-min))
            (while (not (eobp))
              (forward-sexp))))
        t)
    nil))</span>

<a id='4926' tid='4925' class='u'>;;;; Initialization
</a>
(<a id='4928' tid='4927' class='u'>paredit-define-keys</a>)
(<a id='4930' tid='4929' class='u'>paredit-annotate-mode-with-examples</a>)
(<a id='4932' tid='4931' class='u'>paredit-annotate-functions-with-examples</a>)

(<a id='4934' tid='4933' class='u'>provide</a> <a id='4936' tid='4935' class='u'>&#39;</a><a id='4938' tid='4937' class='u'>paredit</a>)

<span class='i'>;;; Local Variables:
</span><span class='i'>;;; outline-regexp: &quot;\n;;;;+&quot;
</span><span class='i'>;;; End:
</span>
<span class='i'>;;; paredit.el ends here
</span>
</pre>
</div>
</body>
</html>
